[TUHS] Bourne shell and comments

Lyndon Nerenberg lyndon at orthanc.ca
Wed Apr 19 10:50:05 AEST 2017


> Ron said:

> I still remember using : for a comment in the V6 shell.   Was also the label
> for goto.

What's cool about ':' vs. '#' is:

-----8<-----8<-----8<-----8<-----8<-----8<-----

function cd {
        command cd "$@" && setprompt
}

function setprompt {
        PS1=": "`id -un`@`hostname|sed 's;\..*$;;'`:'${PWD}; '; export PS1
}

setprompt

-----8<-----8<-----8<-----8<-----8<-----8<-----

Stick that in your .env and you get a snarf-and-barf'able shell prompt that evals as a noop.  Blatantly ripped off from plan9port IIRC.  I run this across all manner of *BSD and Solaris and Linux and it just works.

--lyndon



More information about the TUHS mailing list