You are not logged in.
I want to have a script both define functions and have the ability to run an external program calling one of them. This is the simplified construct:
#!/bin/bash
foo() {
echo "this is foo"
}
bar() {
echo "this is bar"
}
case "$1" in
one)
foo
;;
two)
export bar
/usr/bin/watch bar
;;
*)
echo $0 "{one|two}"
exit 0
;;
esac
So if I invoke /path/to/script one the foo function runs and it exits as expected. I want to ability to run the bar function as if it were a stand-alone program via `/usr/bin/watch bar` but this doesn't work as expected.
$ /path/to/script two
Every 2.0s: bar Mon Jul 30 01:52:15 2012
sh: bar: command not found
How can I accomplish it?
Last edited by graysky (2012-07-30 07:16:56)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Thanks halhen!
...now why didn't the man page for export show me that? I do see it here but not from a `man export`
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Offline
To expand slightly on that, export(1p) comes from the man-page project, but the export command you're actually using is a bash built-in, and is therefore documented in the bash man page.
Offline