From 0403a26b156247e1513f440a6d8531af97be5b0f Mon Sep 17 00:00:00 2001 From: Usaim Bhayat Date: Wed, 22 Mar 2023 18:01:14 -0400 Subject: [PATCH] Added - and _ to the allowed alias name whitelist. --- aliaser | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/aliaser b/aliaser index 79f4e58..024ceb0 100755 --- a/aliaser +++ b/aliaser @@ -1,18 +1,18 @@ #!/bin/bash -version="1.3.1" +version="1.3.2" function print_version { echo $version } function print_add_usage { - echo "usage: aliaser add " + echo "usage: aliaser add " echo " The alias name must not contain any spaces" } function print_remove_usage { - echo "usage: aliaser rm " + echo "usage: aliaser rm " echo " The alias name must not contain any spaces" } @@ -25,11 +25,11 @@ function print_help { echo " ls" echo " Lists all aliases saved in the aliases file, in alphabetical order" echo - echo " add " + echo " add " echo " Creates/replaces an alias for the specified command in the aliases file" - echo " The alias name must not contain any spaces, and can only consist of alphanumeric characters" + echo " The alias name must not contain any spaces, and can only consist of the following characters: a-z A-Z 0-9 _ -" echo - echo " rm " + echo " rm " echo " Removes the alias permanently from the aliases file" echo " The alias name must not contain any spaces" echo @@ -52,8 +52,8 @@ function list_aliases { } function add_alias { - if [[ $alias =~ [^0-9A-Za-z]+ ]]; then - echo "Alias name can only contain alphanumeric characters" + if [[ $alias =~ [^0-9A-Za-z_-]+ ]]; then + echo "Alias name can only contain the following characters: a-z A-Z 0-9 _ -" exit 1 fi count=`grep -o "^alias $alias=" $alias_file | wc -l`