Re: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)
On Feb 24, 2010, at 05:19 , Roman Cheplyaka wrote: Well, this agrees with POSIX. So still I don't see the difference between "$@" and ${1+"$@"}. The difference is that Unix /bin/sh predates POSIX, and on systems that usefully support a notion of backward compatibility (nostly commercial, because (1) they have installed user bases that predate POSIX and (2) they actually think it's worthwhile to support said user bases) /bin/sh uses the traditional behavior that "$@" expands to "" if there are no arguments. (This is "stupid" but consistent, another concept that seems to have been thrown to the wolves.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)
Quoth Roman Cheplyaka , ... > Well, this agrees with POSIX. So still I don't see the difference > between "$@" and ${1+"$@"}. Whatever the standards etc. may say, I believe "$@" is reliably the same as ${1+"$@"}, for old Bourne shells and new. Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)
* Magnus Therning [2010-02-24 09:11:54+] > On Wed, Feb 24, 2010 at 07:18, Roman Cheplyaka wrote: > > * Brandon S. Allbery KF8NH [2010-02-24 00:02:12-0500] > >> On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: > >> >* Anthony Cowley [2010-02-21 14:15:00-0500] > >> >>#! /usr/bin/env bash > >> >>./prog --RTS $* > >> > > >> > ./prog --RTS "$@" > >> > > >> >Otherwise it will work wrong if arguments contain quoted field > >> >separators (e.g. spaces). > >> > >> > >> #! /bin/sh > >> ./prog --RTS ${1+"$@"} > >> > >> The longer specification above should work with whatever /bin/sh is > >> around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux > >> bash, Debian/Ubuntu dash, etc. > > > > Are you referring to some Solaris shell bug? > > > > Under POSIX these constructs seem to be equivalent. > > "If there are no positional parameters, the expansion of '@' shall > > generate zero fields, even when '@' is double-quoted." > > I believe he's referring to the following bit (taken from bash's man page): > > @ Expands to the positional parameters, starting from one. When the expansion > occurs within double quotes, each parameter expands to a separate word. > That > is, "$@" is equivalent to "$1" "$2" ... If the double-quoted expansion > occurs within a word, the expansion of the first parameter is joined with > the beginning part of the original word, and the expansion of the last > parameter is joined with the last part of the original word. When there are > no positional parameters, "$@" and $@ expand to nothing (i.e., they are > removed). Well, this agrees with POSIX. So still I don't see the difference between "$@" and ${1+"$@"}. -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)
On Wed, Feb 24, 2010 at 07:18, Roman Cheplyaka wrote: > * Brandon S. Allbery KF8NH [2010-02-24 00:02:12-0500] >> On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: >> >* Anthony Cowley [2010-02-21 14:15:00-0500] >> >>#! /usr/bin/env bash >> >>./prog --RTS $* >> > >> > ./prog --RTS "$@" >> > >> >Otherwise it will work wrong if arguments contain quoted field >> >separators (e.g. spaces). >> >> >> #! /bin/sh >> ./prog --RTS ${1+"$@"} >> >> The longer specification above should work with whatever /bin/sh is >> around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux >> bash, Debian/Ubuntu dash, etc. > > Are you referring to some Solaris shell bug? > > Under POSIX these constructs seem to be equivalent. > "If there are no positional parameters, the expansion of '@' shall > generate zero fields, even when '@' is double-quoted." I believe he's referring to the following bit (taken from bash's man page): * Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, it expands to a single word with the value of each parameter separated by the first character of the IFS special variable. That is, "$*" is equivalent to "$1c$2c...", where c is the first character of the value of the IFS variable. If IFS is unset, the parameters are separated by spaces. If IFS is null, the parameters are joined without intervening separators. @ Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" ... If the double-quoted expansion occurs within a word, the expansion of the first parameter is joined with the beginning part of the original word, and the expansion of the last parameter is joined with the last part of the original word. When there are no positional parameters, "$@" and $@ expand to nothing (i.e., they are removed). /M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)
* Brandon S. Allbery KF8NH [2010-02-24 00:02:12-0500] > On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: > >* Anthony Cowley [2010-02-21 14:15:00-0500] > >>#! /usr/bin/env bash > >>./prog --RTS $* > > > > ./prog --RTS "$@" > > > >Otherwise it will work wrong if arguments contain quoted field > >separators (e.g. spaces). > > > #! /bin/sh > ./prog --RTS ${1+"$@"} > > The longer specification above should work with whatever /bin/sh is > around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux > bash, Debian/Ubuntu dash, etc. Are you referring to some Solaris shell bug? Under POSIX these constructs seem to be equivalent. "If there are no positional parameters, the expansion of '@' shall generate zero fields, even when '@' is double-quoted." -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe