diff options
| author | Miquel Sabaté <msabate@suse.com> | 2015-07-28 10:01:01 +0200 |
|---|---|---|
| committer | Miquel Sabaté <msabate@suse.com> | 2015-07-28 10:01:01 +0200 |
| commit | 8b873f3d5e4b9f01634fdc886109d7ba90d2e545 (patch) | |
| tree | aa16741245daf2b4644472ba9bd3e37ee41ba91d /g.sh | |
| parent | e7acbf93173469f8dd450961419a1f36c5adf555 (diff) | |
| download | g-8b873f3d5e4b9f01634fdc886109d7ba90d2e545.tar.gz g-8b873f3d5e4b9f01634fdc886109d7ba90d2e545.zip | |
Don't allow the user to add shortcuts whose name conflict with commands
Diffstat (limited to 'g.sh')
| -rw-r--r-- | g.sh | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -63,9 +63,20 @@ save_shortcuts() { done } +# Returns true if the given parameter is a keyword, false otherwise. +is_keyword() { + case "$1" in + add | rm | list | -v | --version | -h | --help) + return 0 + ;; + *) + return 1 + esac +} + # The main function for this script. g() { - version="0.3.3" + version="0.3.4" cmd="$1" gfile=$HOME/.gfile declare -A gshortcuts @@ -95,6 +106,10 @@ g() { return fi fi + if is_keyword $2; then + echo "Cannot use '$2': keyword." + return + fi get_shortcuts gshortcuts[$2]=$path save_shortcuts |
