[PATCH] small test for Bug 12558

Martin Schwenke martin at meltin.net
Mon Apr 10 11:59:14 UTC 2017

On Sun, 9 Apr 2017 10:37:03 +0200, vl--- via samba-technical
<samba-technical at lists.samba.org> wrote:

> If someone know the shell quoting magic to get this under 80 columns,
> I'll be happy to change this :-)

Not in the way it is currently done.  The eval is there to expand "$@",
which just seems crazy.  In other places the only reason the command is
assigned to a variable is so it can be printed before running it.
You're not doing that in this case so you could just put the command in
the sub-shell.

However, if you want to print the command then doing something like
the following seems like a reasonable approximation:

    out=$(set -x; \
	  $SMBCLIENT "$@" \
		-U$USERNAME%$PASSWORD //$SERVER/msdfs-share \
		-I $SERVER_IP $ADDARGS -m nt1 -c dir 2>&1)

You get sane quoting (in fact you can sensibly quote whatever you like,
such as "$SMBCLIENT") and the "set -x" causes the command to be printed
with leading "+ ".

If you don't want the leading "+ " then you can set PS4="" in the
sub-shell before the "set -x":

    out=$(PS4=""; set -x; \
	  $SMBCLIENT "$@" \
		-U$USERNAME%$PASSWORD //$SERVER/msdfs-share \
		-I $SERVER_IP $ADDARGS -m nt1 -c dir 2>&1)

PS4 could be set globally for the whole script... but that might
confuse anyone who runs the script with an explicit "sh -x ..." for
debugging.  :-)

peace & happiness,

More information about the samba-technical mailing list