You are not logged in.
Pages: 1
hey,
im trying to pass to a bash procedure my command line parameters, and im using "set" command to expand the parameters. however, i dont want it to break parameters which are inclused with double-quotes and separated by spaces. here is a test case :
#!/bin/bash
test()
{
set $*
echo p1=$1
echo p2=$2
}
echo p1=$1
echo p2=$2
echo ---
test $*
test case result:
[ziggy@localhost]# ./test 1 "2 3"
p1=1
p2=2 3
---
p1=1
p2=2
as you can see, the formatting of the command line is perfect, but the test() procedure breaks it. any way of accomplishing the same in the test() procedure?
thanks.
Offline
#!/bin/bash
test()
{
set "$@"
echo p1=$1
echo p2=$2
}
echo p1=$1
echo p2=$2
echo ---
test "$@"
The "$@" preserves "2 3" as a single 'word'.
Offline
Offline
Pages: 1