You are not logged in.
Why doesn't the 'export -f FUNCTION' work as expected in the following:
#!/bin/bash
target="$1"
[[ -z "$target" ]] && echo "No target specified." && exit 1
work() {
bsdtar -xOf "$target" .PKGINFO | egrep -w 'pkgname|arch|pkgdesc|group|conflict|depend|replaces' | sed -e 's/pkgname/\npkgname/' >> /scratch/pkgs.log
}
export -f work
find /scratch/repo -name "$target*.pkg.tar.xz" | parallel work
It errors out when called:
% ~/bin/repo/check_pkgs broadcom
zsh:1: command not found: do_work
zsh:1: command not found: do_work
zsh:1: command not found: do_work
zsh:1: command not found: do_work
zsh:1: command not found: do_work
zsh:1: command not found: do_work
zsh:1: command not found: do_work
zsh:1: command not found: do_work
zsh:1: command not found: do_work
zsh:1: command not found: do_work
zsh:1: command not found: do_work
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
My try running this from bash?
Linux odin 3.13.1-pf #1 SMP PREEMPT Wed Mar 5 21:47:28 CET 2014 x86_64 GNU/Linux
Offline
Yep... Same result.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
The command you are exporting is called work.
The command it fails on is do_work
so something's not right.
You're just jealous because the voices only talk to me.
Offline
It's also the wrong solution to be exporting functions...
Yay for ineffective crossposting... https://bbs.archlinux.org/viewtopic.php?id=153461
Offline
Why does zsh report a problem with a bash script?
Offline
The command you are exporting is called work. The command it fails on is do_work
That was a copy/paste error based on me trying multiple scripts. Sorry about the confusion.
% ./test linux
zsh:1: command not found: work
zsh:1: command not found: work
It's also the wrong solution to be exporting functions...
Yay for ineffective crossposting... https://bbs.archlinux.org/viewtopic.php?id=153461
Exporting functions is recommended in the parallel man page.
The command must be an executable, a script, a composed command, or a function. If it is a function you need to export -f the function first. An alias will, however, not work (see why http://www.perlmonks.org/index.pl?node_id=484296).
Also, how is this a cross post? The post you referenced is about parsing input, this one is about calling a function from within the parent script.
Why does zsh report a problem with a bash script?
No idea
Last edited by graysky (2012-11-24 14:35:15)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Ah! The problem is with zsh which is somehow ignoring the shebang in my script! If I run it from a native bash prompt, it works as expected...why?
Last edited by graysky (2012-11-24 16:51:01)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline