projects
/
mdk.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
50e33cb
)
Bash aliases support arguments
author
Frederic Massart
<fred@moodle.com>
Thu, 21 Feb 2013 09:05:48 +0000
(17:05 +0800)
committer
Frederic Massart
<fred@moodle.com>
Thu, 21 Feb 2013 09:05:48 +0000
(17:05 +0800)
moodle
patch
|
blob
|
history
diff --git
a/moodle
b/moodle
index
c33c314
..
130f627
100755
(executable)
--- a/
moodle
+++ b/
moodle
@@
-53,9
+53,14
@@
ALIAS=`$BIN show $COMMAND`
if [ -n "$ALIAS" ]
then
- # It's a shell command.
+ # It's a shell command.
Let's substitute the arguments.
if [[ ${ALIAS:0:1} == '!' ]]; then
- ${ALIAS:1}
+ CMD="${ALIAS:1}"
+ for ((I = 2; I <= $#; I++)); do
+ ARG=${@:I:1}
+ CMD=${CMD//\$$((I-1))/$ARG}
+ done
+ $CMD
exit $?
fi
# If we're here, it's not a shell command. Let's parse the command and arguments.