1. Russ Cox
  2. plan9port
  3. Issues


Issue #74 resolved

Portability of scripts with '9'

Maurício CA
created an issue

If plan9port installs were supposed to have a soft link to '9' script at /usr/bin we could have a portable way of starting scripts:

{{{#!/usr/bin/9 rc}}}

Today we can use, say, {{{#!/usr/bin/env rc}}}, but that now breaks in my system (arch linux) where {{{rc}}} is a system initialization script.

The only change to code is to add a couple lines to {{{INSTALL}}} script:

{{{ echo " Add these to your profile environment." echo " PLAN9=$PLAN9 export PLAN9" echo ' PATH=$PATH:$PLAN9/bin export PATH' echo " If this is a system installation, add '9' to /usr/bin." echo " ln -s $PLAN9/bin/9 /usr/bin/" }}}

Comments (3)

  1. Ethan Grammatikidis

    #!/usr/bin/9 rc

    ^ Only works in Linux. Well, specifically, I tested Darwin and (iirc) OpenBSD and found they refused to run scripts where the #! references another script. The error message is "bad interpreter."

  2. Maurício CA reporter

    I see it could also not work with other tools beside rc. Say, #!/usr/bin/9 awk -f would try to call a program named awk -f, not awk with -f option.

    What about requiring just rc to be linked from /bin and listed in /etc/shells? This seems to be reasonably portable.

  3. Maurício CA reporter

    I've investigated a few alternatives, and it seems there's no 100% solution. Even /usr/bin directory seems to be somewhere else, according to Posix documentation.

    Maybe the best alternative is just to adapt installation of custom scripts to change paths at first line. That's what Posix recommend to its own shell scripts, see


    So. I'm changing this to solved.

  4. Log in to comment