That's particularly useful
when there are embedded spaces and quotes in your arguments...
-------------------------------------------------
#! /bin/bash
echo "argcount: $#"
for (( i=1 ; i<=$#; i++))
do
echo "${i}:${!i}"
done
-------------------------------------------------
At the command line I verify the script:
-------------------------------------------------
$ ./modules/printargs A B "C with spaces" D
argcount: 4
1:A
2:B
3:C with spaces
4:D
$
-------------------------------------------------
(Four arguments, the third being three words with embedded spaces.)
I then run it from within our CFEngine framework:
-------------------------------------------------
commands:
any::
"$(gcom.modulesdir)/printargs"
arglist => { "A", "B", "C with spaces", "D" };
-------------------------------------------------
But instead of receiving four arguments, it receives six: here's the CFE "inform" output:
-------------------------------------------------
info: Executing 'no timeout' ... '[...]/modules/printargs A B C with spaces D'
notice: Q: ".../printargs A B ": argcount: 6
Q: ".../printargs A B ": 1:A
Q: ".../printargs A B ": 2:B
Q: ".../printargs A B ": 3:C
Q: ".../printargs A B ": 4:with
Q: ".../printargs A B ": 5:spaces
Q: ".../printargs A B ": 6:D
info: Last 7 quoted lines were generated by promiser
-------------------------------------------------
That useful "embedded spaces" claim in the documentation seems to be being ignored.
Is the bug/problem:
- in the code
- or in the documentation
- or in my interpretation of the documentation
Help appreciated
-- David Lee