Skip to content

Instantly share code, notes, and snippets.

@mattieb
Created November 19, 2013 16:39
Show Gist options
  • Save mattieb/7548324 to your computer and use it in GitHub Desktop.
Save mattieb/7548324 to your computer and use it in GitHub Desktop.
bashing bash
megaweapon:tmp matt$ mkdir -p foo/baz
megaweapon:tmp matt$ cd foo
megaweapon:foo matt$ PATH=/tmp/foo/baz:/tmp/foo:$PATH
megaweapon:foo matt$ cat >bar
#!/bin/sh
echo "this isn't the bar you're looking for"
megaweapon:foo matt$ chmod +x bar
megaweapon:foo matt$ bar
this isn't the bar you're looking for
megaweapon:foo matt$ cat >baz/bar
#!/bin/sh
echo "this IS the bar you're looking for"
megaweapon:foo matt$ chmod +x baz/bar
megaweapon:foo matt$ bar
this isn't the bar you're looking for
megaweapon:foo matt$ which bar
/tmp/foo/baz/bar
megaweapon:foo matt$ hash -r
megaweapon:foo matt$ bar
this IS the bar you're looking for
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment