trinity-users@lists.pearsoncomputing.net

Message: previous - next
Month: August 2018

Re: [trinity-users] update this morning=347 pkgs from trinity?

From: Michael <mb_trinity_desktop@...>
Date: Wed, 1 Aug 2018 18:31:13 -0500
On Wednesday 01 August 2018 03:09:19 pm Stefan Krusche wrote:
> Am Mittwoch 01 August 2018 schrieb Michael:
> > and modifying the '/usr/bin/ni' script to:
> >
> > michael@local [~]# cat /usr/bin/no-internet
> > #!/bin/bash
> > COMMAND="$1"
> > shift
> > for arg; do
> > COMMAND="$COMMAND \"$arg\""
> > done
> > sg no-internet "$COMMAND"
>
> Why not just:
>
> sg no-internet "$@"
>
> which would do the same as the code above, AFAIU.

Hi Stefan,

It doesn't do the same, but it's not my code, so...

AFAIR the difference is in how shell does the expansion, where "$@" can break 
single arguments in to garbage because of white spacing and the 
COMMAND="$COMMAND \"$arg\"" re-adds quotes properly to not break single 
arguments that have white space.  (Or less likely it was an sg issue of passed 
in arguments?)

The full explanation is (was) buried on that thread somewhere, or on something 
that thread links(ed) to.  It made sense to do at the time, but I'd need 
someone else with a much better depth of skill with bash/shell/sg to 
authoritatively explain it.

Best,
Michael