Skip to content

Commit

Permalink
Added - and _ to the allowed alias name whitelist.
Browse files Browse the repository at this point in the history
  • Loading branch information
bhayatus committed Mar 22, 2023
1 parent e40cf13 commit 0403a26
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions aliaser
Original file line number Diff line number Diff line change
@@ -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 <alias> <command>"
echo "usage: aliaser add <alias_name> <command>"
echo " The alias name must not contain any spaces"
}

function print_remove_usage {
echo "usage: aliaser rm <alias>"
echo "usage: aliaser rm <alias_name>"
echo " The alias name must not contain any spaces"
}

Expand All @@ -25,11 +25,11 @@ function print_help {
echo " ls"
echo " Lists all aliases saved in the aliases file, in alphabetical order"
echo
echo " add <alias> <command>"
echo " add <alias_name> <command>"
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 <alias>"
echo " rm <alias_name>"
echo " Removes the alias permanently from the aliases file"
echo " The alias name must not contain any spaces"
echo
Expand All @@ -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`
Expand Down

0 comments on commit 0403a26

Please sign in to comment.