zsh-users
 help / color / mirror / code / Atom feed
* zsh will not run scripts as /bin/bash even with #!/bin/bash as the first line
@ 2012-11-25  1:07 John
  2012-11-25  2:41 ` Yichao Yu
  2012-11-25  2:42 ` Kurtis Rader
  0 siblings, 2 replies; 6+ messages in thread
From: John @ 2012-11-25  1:07 UTC (permalink / raw)
  To: zsh-users

Been using zsh for a while now and loving it.  I ran into a problem today.  The following script errors out if run with zsh as my default shell:

#!/bin/bash
v_build() {

echo "The file is $1"
}

export -f v_build
find . -maxdepth 1 -type f | parallel v_build

Output:
% ./test 
zsh:1: command not found: v_build
zsh:1: command not found: v_build
zsh:1: command not found: v_build
zsh:1: command not found: v_build

If I switch to a user who has bash as its default shell, the same script runs just fine:

$ ./test
The file is ./test
The file is ./01.jpg
The file is ./02.jpg
The file is ./03.jpg

Love to understand what I have incorrectly configured.  It seems like zsh is ignoring the shebang telling it to use /bin/bash as the shell to run the script.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: zsh will not run scripts as /bin/bash even with #!/bin/bash as the first line
  2012-11-25  1:07 zsh will not run scripts as /bin/bash even with #!/bin/bash as the first line John
@ 2012-11-25  2:41 ` Yichao Yu
  2012-11-25  4:22   ` John
  2012-11-25  2:42 ` Kurtis Rader
  1 sibling, 1 reply; 6+ messages in thread
From: Yichao Yu @ 2012-11-25  2:41 UTC (permalink / raw)
  To: John; +Cc: zsh-users

On Sat, Nov 24, 2012 at 8:07 PM, John <da_audiophile@yahoo.com> wrote:
> Been using zsh for a while now and loving it.  I ran into a problem today.  The following script errors out if run with zsh as my default shell:
>
> #!/bin/bash
> v_build() {
>
> echo "The file is $1"
> }
>
> export -f v_build
> find . -maxdepth 1 -type f | parallel v_build
>
> Output:
> % ./test
> zsh:1: command not found: v_build
> zsh:1: command not found: v_build
> zsh:1: command not found: v_build
> zsh:1: command not found: v_build

Ur main script is indeed run by bash but parallel is trying to execute
the v_build command in your default shell.... therefore it has nothing
to do with the #! line...

Not sure how to solve this problem though....

>
> If I switch to a user who has bash as its default shell, the same script runs just fine:
>
> $ ./test
> The file is ./test
> The file is ./01.jpg
> The file is ./02.jpg
> The file is ./03.jpg
>
> Love to understand what I have incorrectly configured.  It seems like zsh is ignoring the shebang telling it to use /bin/bash as the shell to run the script.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: zsh will not run scripts as /bin/bash even with #!/bin/bash as the first line
  2012-11-25  1:07 zsh will not run scripts as /bin/bash even with #!/bin/bash as the first line John
  2012-11-25  2:41 ` Yichao Yu
@ 2012-11-25  2:42 ` Kurtis Rader
  1 sibling, 0 replies; 6+ messages in thread
From: Kurtis Rader @ 2012-11-25  2:42 UTC (permalink / raw)
  To: John; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1431 bytes --]

The shell, whether zsh or bash, does not pay any attention to the shebang
line. That is done by the operating system kernel. That is, when you
execute a shell script the OS notices that the file is a plain text file
with a "#!" signature and launches the named program to interpret its
contents.

You cannot reasonably expect exported functions to work across different
shells. Put the function in a script file and reference that as your
argument to the parallel command.

On Sat, Nov 24, 2012 at 5:07 PM, John <da_audiophile@yahoo.com> wrote:

> Been using zsh for a while now and loving it.  I ran into a problem today.
>  The following script errors out if run with zsh as my default shell:
>
> #!/bin/bash
> v_build() {
>
> echo "The file is $1"
> }
>
> export -f v_build
> find . -maxdepth 1 -type f | parallel v_build
>
> Output:
> % ./test
> zsh:1: command not found: v_build
> zsh:1: command not found: v_build
> zsh:1: command not found: v_build
> zsh:1: command not found: v_build
>
> If I switch to a user who has bash as its default shell, the same script
> runs just fine:
>
> $ ./test
> The file is ./test
> The file is ./01.jpg
> The file is ./02.jpg
> The file is ./03.jpg
>
> Love to understand what I have incorrectly configured.  It seems like zsh
> is ignoring the shebang telling it to use /bin/bash as the shell to run the
> script.
>



-- 
Kurtis Rader
Caretake of the exceptional canines Junior and Chino

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: zsh will not run scripts as /bin/bash even with #!/bin/bash as the first line
  2012-11-25  2:41 ` Yichao Yu
@ 2012-11-25  4:22   ` John
  2012-11-25  5:05     ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: John @ 2012-11-25  4:22 UTC (permalink / raw)
  To: Yichao Yu; +Cc: zsh-users

> Ur main script is indeed run by bash but parallel is trying to execute

> the v_build command in your default shell.... therefore it has nothing
> to do with the #! line...
> 
> Not sure how to solve this problem though....


You are right.  I have been combing through the man page looking for a switch to override the default shell but haven't found one.  Feature request?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: zsh will not run scripts as /bin/bash even with #!/bin/bash as the first line
  2012-11-25  4:22   ` John
@ 2012-11-25  5:05     ` Bart Schaefer
  2012-11-25 15:09       ` John
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2012-11-25  5:05 UTC (permalink / raw)
  To: zsh-users

On Nov 24,  8:22pm, John wrote:
} Subject: Re: zsh will not run scripts as /bin/bash even with #!/bin/bash a
}
} > Ur main script is indeed run by bash but parallel is trying to execute
} > the v_build command in your default shell.... therefore it has nothing
} > to do with the #! line...
}
} You are right. I have been combing through the man page looking for a
} switch to override the default shell but haven't found one.

Try

    find . -maxdepth 1 -type f | SHELL=/bin/bash parallel v_build



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: zsh will not run scripts as /bin/bash even with #!/bin/bash as the first line
  2012-11-25  5:05     ` Bart Schaefer
@ 2012-11-25 15:09       ` John
  0 siblings, 0 replies; 6+ messages in thread
From: John @ 2012-11-25 15:09 UTC (permalink / raw)
  To: Bart Schaefer, zsh-users

----- Original Message -----

> From: Bart Schaefer <schaefer@brasslantern.com>
> To: "zsh-users@zsh.org" <zsh-users@zsh.org>
> Cc: 
> Sent: Sunday, November 25, 2012 12:05 AM
> Subject: Re: zsh will not run scripts as /bin/bash even with #!/bin/bash as the first line
> Try
> 
>     find . -maxdepth 1 -type f | SHELL=/bin/bash parallel v_build
> 

Brilliant!  This works great.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-25 15:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-25  1:07 zsh will not run scripts as /bin/bash even with #!/bin/bash as the first line John
2012-11-25  2:41 ` Yichao Yu
2012-11-25  4:22   ` John
2012-11-25  5:05     ` Bart Schaefer
2012-11-25 15:09       ` John
2012-11-25  2:42 ` Kurtis Rader

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).