git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t5528: do not fail with FreeBSD shell

From
Kyle J. McKay <mackyle@gmail.com>
Date
Mar 9, 2015, 05:19 UTC
Message-ID
<211E8F7E-5588-45B1-ACF6-BB7DFB798ABB@gmail.com>
In-Reply-To
<20150308175624.GA30399@peff.net>
On Mar 8, 2015, at 10:56, Jeff King wrote:
Show 19 quoted lines
> On Sun, Mar 08, 2015 at 08:37:50AM -0700, Kyle J. McKay wrote:
>
>> The FreeBSD shell converts this expression:
>>
>>  git ${1:+-c push.default="$1"} push
>>
>> to this when "$1" is not empty:
>>
>>  git "-c push.default=$1" push
>>
>> which causes git to fail.
>
> Hmph, just when I thought I knew about all of the weird shell  
> quirks. :)
>
> I am not convinced this isn't a violation of POSIX (which specifies  
> that
> field splitting is done on the results of parameter expansions outside
> of double-quotes). But whether it is or not, we have to live with it.

That's not the only problem the shell has, t5560 had an issue, rebase had issues. They've have been worked around. It probably also affects related BSDs' shells as well (at least older versions that didn't change the shell).

Show 12 quoted lines
> For my own curiosity, what does:
>
>  foo='with space'
>  printf "%s\n" ${foo:+first "$foo"}
>
> print? That is, are the double-quotes even doing anything on such a
> shell? On bash and dash, it prints:
>
>  first
>  with space
>
> which is what I would expect.

$ foo='with space' $ printf "%s\n" ${foo:+first "$foo"} first with space

I also happen to have a handy-dandy test program called "showargs".

$ foo='with space' $ showargs ${foo:+first "$foo"} uid=1001 euid=1001 gid=1001 egid=1001 umask(octal)=022 stdin=/dev/pts/12 stdout=/dev/pts/12 stderr=/dev/pts/12 pid=5261 $0=showargs $1=first with space

So no quotes are being passed on.  Of course bash works just fine.
> So does "ash" (0.5.7, packaged for
> Debian), which is what I _thought_ FreeBSD's shell was based on. But
> clearly there is some divergence.

I like to test on FreeBSD 8, which is slightly older, once in a while to make sure I catch stuff like this. :)

Running "ident /bin/sh" shows a bunch of source file names which matches up pretty well with the dash distribution so I'm pretty sure it's just a much older ancestor of dash/ash.

If I run dash 0.5.6 (installed via FreeBSD ports), it works properly too.

> I guess they are getting eaten by your shell, otherwise we would pass
> them along to git in the test script, which would complain.

When I run t5528 with -v -x -d -i this is where it dies (without the fix):

+ git '-c push.default=upstream' push
Unknown option: -c push.default=upstream
So yeah, the quotes are gone, but no word-splitting occurred.
Previous: Jeff KingNext: Jeff King
Message 3 of 4 in “t5528: do not fail with FreeBSD shell”
  1. t5528: do not fail with FreeBSD shellKyle J. McKay, Mar 8, 2015
  2. Jeff KingMar 8, 2015
  3. Kyle J. McKayMar 9, 2015
  4. Jeff KingMar 9, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.