Russ Cox is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

rsc / plan9port http://swtch.com/plan9port/

Plan 9 from User Space (aka plan9port) is a port of many Plan 9 programs from their native Plan 9 environment to Unix-like operating systems. See the web site http://swtch.com/plan9port/ for details.

Clone this repository (size: 58.2 MB): HTTPS / SSH
hg clone https://bitbucket.org/rsc/plan9port
hg clone ssh://hg@bitbucket.org/rsc/plan9port

Issues

#74 Portability of scripts with '9'

Reported by Maurício CA

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/"
Status: resolved Responsible: nobody Type: proposal Priority: major
Milestone: none Component: none Version: none

Attachments

No attachments added for this issue yet.

Comments and changes

  1. #1 Ethan Grammatikidis

    written

    #!/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. #2 Maurício CA

    written

    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. #3 Maurício CA

    written

    • Changed status from new to resolved.

    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

    http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html

    So. I'm changing this to solved.

Add comment / attachment

Verification: Please write the text from the image in the box (letters only)

captcha

Is that you, Humanoid? Is this me?