|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
hi,
how do we make a user-defined function in bourne shells to be able to take it's input(s) from either it's argument list or a heredoc? For example, func1() { printf '%s\n' "$@" return 0 } func1 "$var1" 'arg2' # works fine when arguments provided # by means of shell variables or hardcoded strings # but this doesnt work func1 << EOF this is some heredoc usage: FOOBAR tmpdir tmpfile codename EOF Regards, Rakesh |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
On 25 Aug 2006 03:40:49 -0700, Rakesh Sharma wrote:
> hi, > > how do we make a user-defined function in bourne shells to be able to > take it's input(s) from either it's argument list or a heredoc? > > For example, > > func1() { > printf '%s\n' "$@" > return 0 > } > > func1 "$var1" 'arg2' # works fine when arguments provided > # by means of shell variables or hardcoded strings > > # but this doesnt work > func1 << EOF > this is some heredoc > usage: FOOBAR tmpdir tmpfile codename > EOF [...] func1() { if [ "$#" -eq 0 ]; then cat else printf '%s\n' "$@" fi return 0 } -- Stephane |
|
![]() |
| Outils de la discussion | |
|
|