help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Expansion of unquoted special parameter $@ when used as the word for


From: Robin A. Meade
Subject: Re: Expansion of unquoted special parameter $@ when used as the word for a HERE STRING
Date: Tue, 5 Nov 2019 12:15:03 -1000

Thanks Branden and Andreas. I confirmed adding double-quotes around the $@
gives the same result as $*, provided IFS has a space as its first
character.

(assuming IFS has a space as its first character)
set -- a 'b   c'
cat <<< "$@" # a b   c
cat <<< $*   # a b   c (same)



On Tue, Nov 5, 2019 at 12:06 PM Andreas Kusalananda Kähäri <
address@hidden> wrote:

> On Wed, Nov 06, 2019 at 08:28:49AM +1100, G. Branden Robinson wrote:
> > At 2019-11-05T10:30:39-1000, Robin A. Meade wrote:
> > > Consider:
> > >
> > > set a 'b   c'
> > > cat <<< $@;
> > >
> > > The output is:
> > >
> > > a b c
> > >
> > > I expected the 3 spaces between b and c to be preserved.
> >
> > You've got to double-quote $@ for it to work the way you desire:
> >
> > cat <<< "$@"
> >
> > Without quoting, $@ works like $*.
>
> ... but only if $IFS has a space as its first character.
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]