dspinellis / dgsh

Shell supporting pipelines to and from multiple processes
http://www.spinellis.gr/sw/dgsh/
Other
323 stars 23 forks source link

Command not found when invoking a function #27

Closed dspinellis closed 7 years ago

dspinellis commented 7 years ago
[dds@stereo dgsh]$ example/5x5.sh
bash: f: command not found
[dds@stereo dgsh]$ cat example/5x5.sh
#!/usr/bin/env dgsh

f()
{
  echo hi
}

call f | paste
mfragkoulis commented 7 years ago

f should be exported:

export -f f

dspinellis commented 7 years ago

Thanks! Can we make this implicit when there is a call statement?

dspinellis commented 7 years ago

Also, the following example also fails.

#!/usr/bin/env dgsh

f()
{
  echo hi | paste
}

export -f f
call f
[dds@stereo dgsh]$ example/5x5.sh
bash: --dgsh-negotiate: invalid option
Usage:  bash [GNU long option] [option] ...
        bash [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --rcfile
        --restricted
        --verbose
        --version
Shell options:
        -ilrsD or -c command or -O shopt_option         (invocation only)
        -abefhkmnptuvxBCHP or -o option
dspinellis commented 7 years ago

The following also fails with the above message

#!/usr/bin/env dgsh

row()
{
  dgsh -c --dgsh-negotiate 'echo hi | paste'
}

export -f row
call row
mfragkoulis commented 7 years ago

The following works:

#!/usr/bin/env dgsh

row()
{
  dgsh -c 'echo hi | paste'
}

export -f row
call row | cat

Why it works:

dspinellis commented 7 years ago

Indeed it works. But we must make it more intuitive.

mfragkoulis commented 7 years ago

Fixed in fd923aa