Re: [PATCH v2] alias: fix name quoting in printalias

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/01/2023 00:30, Harald van Dijk wrote:
On 09/01/2023 00:15, наб wrote:
single_quote() over-writes the stack string, so just output the name
separately first.

Fixes: commit 4ec545e8dc98a3f461cf56bed03adafa81c64aec ("alias: Quote
  name in printalias")
---
really not my year sorry

This one works, thanks.

I'm wondering if we can save on code size by storing aliases differently instead, allowing for a simpler fix here. If we store aliases in memory in name=value form in a single block of memory, we only need a single savestr() when creating the alias, we only need a single single_quote() call here, we only need a single free() when we're done with the alias, and may be able to share some code with src/var.c for checking the alias name and stopping at the '='.

That'd be a larger change though, and even if it is possible, I am not sure it's worth it.

Having implemented this, I am also seeing that this does achieve the result of reducing code size. The only visible change is that given e.g.

  alias foo=bar
  alias foo

we get

  'foo=bar'

rather than

  'foo'='bar'

which should be equally acceptable.

If there is interest in having this in dash, can adapt and submit it.

Cheers,
Harald van Dijk



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux