Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Passing parameters between noninteractive shells



On Oct 25, 12:45pm, Phil Pennock wrote:
}
} exec $HOME/bin/zsh "$@"

I always use

    export SHELL=$HOME/bin/zsh
    exec $SHELL -$- "$@"

Options passed to the shell are not present in "$@", you have to get them
from "$-".  That does potentially miss a few, as there are not values in
$- for all possible setopts, but it preserves things like "-l" for a
login shell.

} With parameters:
}  alpha
}  foo bar
}  wibble
} 
} then:
}  "$*" == 'alpha foo bar wibble'
}  "$@" == 'alpha' 'foo bar' 'wibble'

And, only in zsh and only with shwordsplit not set,

    $*  == "$@"

} (ie, _most_ times that you see $* in a script it's a bug, normally "$@"
}  is what's needed)

That statement is true for scripts that are meant to be portable among
various implementations of POSIX/Bourne-like shells.



Messages sorted by: Reverse Date, Date, Thread, Author