Re: [PATCH] posix compatibility: remove use of ansi-c quoting

Message ID
DKIM signature
Download raw message
On Thu, Aug 10, 2023, at 5:38 PM, Bernhard wrote:
> On Thu, 10 Aug 2023 16:39:42 -0400
> "Miles Alan" <m@milesalan.com> wrote:
>> On Tue, Jul 25, 2023, at 4:46 PM, nycex wrote:
>> > +    newline="$(printf '\nx')"
>> > +    newline="${newline%x}"
>> >      RESULT="$(
>> >        echo "$OPTS" |
>> > -      xargs -d$'\n' zenity $(zenitydims 0.8 0.8) --title "Select
>> > an entry" --list --column=Selection --text "$PROMPT"
>> > +      xargs -d"$newline" zenity $(zenitydims 0.8 0.8) --title
>> > "Select an entry" --list --column=Selection --text "$PROMPT"  
>> Thanks for sending - sorry about the delay, this got lost on me. This
>> is one of those sharp edges of shell where I'm not really sure of the
>> 'best' solution. Do you know of any doc on ansi-c quoting and best
>> practices as described? E.g. is this method you sent commonly
>> prescribed somewhere?
>> Curious - would `xargs -d"\\n"` work alternatively for you?
>> Miles
> When researching this issue I came across this post:
> https://unix.stackexchange.com/questions/467720/how-to-correctly-store-a-newline-character-in-a-posix-shell-variable.
> The problem is, the POSIX standard does not define the $"..." style
> quotes (which allows to get escape sequences in strings). Mepo uses
> /bin/sh in its shebang, so it breaks on systems where /bin/sh isn't
> linked to bash (I think this is the case for debian (uses dash afaik),
> to mention a prominent example).
> However, I didn't realize xargs itself actually supported escape codes
> for their delimiter. This means that your suggestion, xargs -d"\\n" is
> probably the best solution. I would send a patch, but I think that it
> would be more work for you to accept the patch than making the change
> itself :).

Sounds good - thanks for the additional note on dash/debian; also tested
against dash locally and seems -d"\\n" should work for bash, ash, and
dash. Pushed update as described to master.

Thanks again for reporting

Reply to thread Export thread (mbox)