Skip to content

Instantly share code, notes, and snippets.

@taylor
Created December 14, 2012 21:07
Show Gist options
  • Save taylor/4288688 to your computer and use it in GitHub Desktop.
Save taylor/4288688 to your computer and use it in GitHub Desktop.
Find the name of the shell script, de-reference symlinks, handle both SOURCED scripts and executed versions.
#!/bin/bash
[[ "$0" = "-bash" ]] && N="$BASH_SOURCE" || N="$0"
me=$(basename `readlink --canonicalize --no-newline $N`)
@wwalker
Copy link

wwalker commented Dec 14, 2012

Slick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment