[TUHS] What was your "Aha, Unix!" moment?

jason-tuhs at shalott.net jason-tuhs at shalott.net
Mon Oct 21 20:45:40 AEST 2019


>> % pwd
>> /usr/ken
>> % cd /tmp
>> % pwd
>> /usr/ken
>>
>> Aha!

> I'm old and slow, had to think about that one.  Aha indeed!

I've actually been asking this (or, as a variation, how a child can set 
environment in its parent) as an interview question for unix sysadmins for 
the past fifteen or so years.  Maybe one in three gets it.

The answer that I'm secretly hoping for, no one has ever yet given me:


hashbrown/home/jason-112719: /bin/pwd
/home/jason

hashbrown/home/jason-112720: ./cd.sh /tmp

hashbrown/home/jason-112721: /bin/pwd
/tmp

hashbrown/home/jason-112722: cat cd.sh
cat: cd.sh: No such file or directory

hashbrown/home/jason-112723: cat ~/cd.sh
#!/bin/sh

test -n "$1" && TARGET=$1 || TARGET=$HOME

( echo "call (int) chdir(\"$TARGET\")" ; echo detach ; echo quit ) | gdb -q -p $PPID >/dev/null 2>&1 &


"With ptrace(2) all things are possible."


  -Jason



More information about the TUHS mailing list