From 553cb2204b0bf27afe13c6332f5679bbd47172a0 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 24 Sep 2025 05:01:20 +0200 Subject: Update/Overhaul --- unix/utils/xtouch | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 unix/utils/xtouch (limited to 'unix/utils/xtouch') diff --git a/unix/utils/xtouch b/unix/utils/xtouch new file mode 100755 index 0000000..a5eb23b --- /dev/null +++ b/unix/utils/xtouch @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +check_valid() { + if [ -f "$1" ]; then + echo "The file "$1" already exists!" + exit 1 + fi +} + +create_script() { + touch "$1" + chmod +x "$1" + echo "$0: $2 script file $1 created with exec permissions" + echo -e '#!/usr/bin/env '"$2" > "$1" +} + +usage() { + echo -e "Quickly create executable script\n" + echo "Usage:" + echo " xtouch [ -w FILE LANG ]" + echo -e " xtouch ( -h | --help )\n" + echo "Arguments:" + echo "FILE Name to give the scripts" + echo -e "LANG Language in which the script will be written\n" + echo "Options:" + echo " -w FILE LANG Creates a executable script file named ." + echo " -h --help Show this screen." +} + +case "$1" in + '-w') + check_valid "$2" + create_script "$2" "$3" + ;; + *) + usage + ;; +esac -- cgit v1.2.3