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

Re: view onto command pipeline?



On Wed, Jul 20, 2022 at 02:22:21PM +0200, Vincent Bernat wrote:
> On 2022-07-20 13:37, Dominik Vogt wrote:
> > On Wed, Jul 20, 2022 at 07:23:46AM -0400, Anthony Heading wrote:
> > >          local opts=()
> > >          if [[ -o interactive && ( -t 1 || -n $pager ) ]]
> > >          then
> > >                  opts=(-c color.ui=always)
> > >          fi
> > >          command git $opts $@
> >
> > For proper handling of whitecpace in options and arguments:
> >
> >    command git "${opts[@]}" "$@"
> >
> > Otherwise, if you have, say, files "a", "b" and "a b",
> >
> >    $ git commit "a b"
> >
> > Would commit a and b but not "a b" if the $@ is not quoted.  As a
> > rule of thumb, _never_ use unquoted variables in shell scripts.
>
> I don't think this is true for Zsh.
>
>  14:21 ??? f() { print -l $@ }
>  14:21 ??? f a b
> a
> b
>  14:21 ??? f "a b"
> a b

Depends on shell options:

  $ function xls () { command ls $@ }
  $ setopt shwordsplit
  $ xls "a b"
  ls: cannot access 'a': No such file or directory
  ls: cannot access 'b': No such file or directory
  $ unsetopt shwordsplit
  $ xls "a b"
  'a b'

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt




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