Created
August 9, 2011 10:55
-
-
Save igrep/1133754 to your computer and use it in GitHub Desktop.
Sample to show that It's more useful to use +eval+ and +source+ if you want to decide which command to execute in your script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Execute command twice. | |
#Sample to show that | |
# It's more useful to use +eval+ and +source+ | |
# if you want to decide which command to execute in your script | |
shopt -s expand_aliases # don't work even if expand_aliases is enabled. | |
# $@ #don't work well: don't expand the alias | |
eval $@ | |
eval $@ | |
#sample | |
# alias foo='echo foo' | |
# ./twice.sh foo # do NOT expand the alias!! | |
# source twice.sh foo # DO expand the alias!! | |
# alias twice='source twice.sh' # you can use it as a command. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment