Mailinglist Archive: opensuse (1264 mails)

< Previous Next >
Re: [opensuse] Quick question: how to call a script function from "find"?
On 06/13/2017 01:55 PM, Carlos E. R. wrote:
On 2017-06-13 13:42, Per Jessen wrote:
Carlos E. R. wrote:

$@? I don't know what that one does. [searching...]

@ Expands to the positional parameters, starting from
one.
When the expansion occurs within double quotes, each parameter expands
to a separate word. That is, "$@" is equivalent to "$1" "$2" ... If
the double-quoted expansion occurs within a word, the expansion of the
first parameter is joined with the beginning part of the original
word, and the expansion of the last parameter is joined with the last
part of the original word. When there are no positional parameters,
"$@" and $@ expand to nothing (i.e., they are removed).


I don't quite see the difference with $* :-?

$* is a single string/argument, $@ is an array.

Ah.

But in this case, both would result in generating the proper command
line to the chmod commands, nor?

Actually, a single argument may be the right thing, being a directory
name with spaces. I may get a name with two spaces!

Well, that's exactly the problem: if the script gets another argument
and that may also have spaces, then the array variant "$@" will work
better.

Thus, I'm almost never using "$*".

And BTW: it's always a good idea to use double quotes around "$@",
because otherwise the called program/snippet will have the same problem
again.

Have a nice day,
Berny

--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups