On Monday 12 July 2010 16:46:22 Atom Smasher wrote: > on freebsd, zsh installs as /usr/local/bin/zsh. on linux (and most other > systems?) it installs as /usr/bin/zsh. > > what's the best way to make zsh script portable between linux and freebsd? > > i could start the script with: > #!/usr/bin/env zsh > > or i could specify that the script be executed as: > zsh script > > is there a better way? Using env doesn't solve the problem either. There is no guarantee the "env" program is installed under /usr/bin/env. It may as well be installed under /usr/local/bin/env. But every unix should have a bourne shell compatible shell located at /bin/sh. You can use a bourne shell compatible code snippet and call zsh from it. If PATH contains zsh than this will do the trick. #!/bin/sh if [ -z "$ZSH_VERSION" ]; then ## searching PATH for zsh executable exec zsh $* < $0 ## no zsh detected exit 1 fi ## zsh should be running now. do zsh stuff print "hello"
Attachment:
signature.asc
Description: This is a digitally signed message part.