You are not logged in.
Pages: 1
I have question, is possible to run .sh scripts under zsh shell?
Offline
Offline
ok, but is necessary to edit this script?
changing #! bash header or something like that...?
Last edited by william7 (2008-07-04 13:12:52)
Offline
ok, but is necessary to edit this script?
changing #! bash header or something like that...?
This #! bash header is the reason why there is no difference between using bash or zsh when executing the script.
Both shells will spawn a bash process for executing the script.
Now if you change that line, you may (or not) get compatibility problems.
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
Both shells will spawn a bash process for executing the script.
Um? If you change the header to #!/bin/zsh, then zsh will run the script, not bash.
If the header is #!/bin/sh, your current shell will decide how to run it. If your current shell is zsh, it will be run by zsh in a POSIX-compatible way.
If the header is #!/bin/bash, then bash will be spawned to run it.
Last edited by buttons (2008-07-04 14:50:46)
Cthulhu For President!
Offline
shining wrote:Both shells will spawn a bash process for executing the script.
Um? If you change the header to #!/bin/zsh, then zsh will run the script, not bash.
If the header is #!/bin/sh, your current shell will decide how to run it. If your current shell is zsh, it will be run by zsh in a POSIX-compatible way.
If the header is #!/bin/bash, then bash will be spawned to run it.
I thought #!/bin/sh emulated the old Bourne shell...?
Offline
You're right. See here for compatibility and differences between it and zsh emulation --> http://zsh.dotsrc.org/FAQ/zshfaq02.html
Cthulhu For President!
Offline
so...
if script is /bin/bash zsh starts bash
but is /bin/sh spcript will be start by zsh...
am I right?
Offline
shining wrote:Both shells will spawn a bash process for executing the script.
Um? If you change the header to #!/bin/zsh, then zsh will run the script, not bash.
Um? Who talked about changing the header? I am talking about a script with /bin/bash header.
If the header is #!/bin/sh, your current shell will decide how to run it. If your current shell is zsh, it will be run by zsh in a POSIX-compatible way.
If the header is #!/bin/bash, then bash will be spawned to run it.
I don't think this is true either. If the header is /bin/sh, the current shell will spawn /bin/sh. On Arch, by default, /bin/sh is a link to /bin/bash, so bash will be used here.
Also, it is worth mentioning that in this case where bash is invoked as sh, it works in some kind of compatibility mode (closer to POSIX?).
And same with zsh if there was a sh -> zsh symlink.
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
I don't think this is true either. If the header is /bin/sh, the current shell will spawn /bin/sh. On Arch, by default, /bin/sh is a link to /bin/bash, so bash will be used here.
Also, it is worth mentioning that in this case where bash is invoked as sh, it works in some kind of compatibility mode (closer to POSIX?).
And same with zsh if there was a sh -> zsh symlink.
This is correct, per the link I posted earlier. Well, dunno about the bash also emulating sh bit. I think it's true.
When sh is linked to zsh, zsh runs the script in Bourne shell (sh) emulation mode.
Cthulhu For President!
Offline
Pages: 1