Verzeichnisse in die korrekte Reihenfolge umbenannt.

This commit is contained in:
2025-06-19 06:24:38 +02:00
parent dcaafa8604
commit 1af089d106
4 changed files with 1 additions and 0 deletions

View File

@@ -1,15 +0,0 @@
#! /usr/bin/bash
case ${1} in
'Homer'|'Marge'|'Bart'|'Lisa')
echo "Familie Simpson"
;;
'Ned'|'Maude'|'Todd'|'Rod')
echo "Familie Flanders"
;;
'Clancy'|'Sarah'|'Ralph')
echo "Familie Wiggum"
;;
esac

View File

@@ -1,9 +0,0 @@
#!/usr/bin/bash
if [[ "$1" == "Homer" || "$1" == "Marge" || "$1" == "Bart" || "$1" == "Lisa" ]]; then
echo "Familie Simpson"
elif [[ "$1" == "Ned" || "$1" == "Maude" || "$1" == "Todd" || "$1" == "Rod" ]]; then
echo "Familie Flanders"
elif [[ "$1" == "Clancy" || "$1" == "Sarah" || "$1" == "Ralph" ]]; then
echo "Familie Wiggum"
fi

70
teil24/parseargs.sh Executable file
View File

@@ -0,0 +1,70 @@
#!/bin/bash
display_help() {
echo "Usage: ${0} [options]"
echo "Options:"
echo " -h, --help Show this help message"
echo " -v, --verbose Enable verbose mode"
echo " -f, --file <file> Specify a file"
echo " -n, --number <num> Specify a number (default: 42)"
}
# Universelle Parameterparser-Funktion
parse_args() {
POSITIONAL=()
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
display_help "$@"
exit 0
;;
-v|--verbose)
VERBOSE=true
shift
;;
-f|--file)
if [[ -z "$2" || "$2" == -* ]]; then
echo "Error: --file requires a non-empty argument."
exit 1
fi
FILE="$2"
shift 2
;;
-n|--number)
if [[ -z "$2" || "$2" == -* ]]; then
echo "Error: --number requires a non-empty argument."
exit 1
fi
NUMBER="$2"
shift 2
;;
--) # Explicit end of options
shift
break
;;
-*) # Unknown option
echo "Error: Unknown option $1"
exit 1
;;
*) # Positional argument
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}" # Restore positional parameters
# Defaults
VERBOSE="${VERBOSE:-false}"
NUMBER="${NUMBER:-42}"
}
# Aufruf der Funktion mit allen Skriptargumenten
parse_args "$@"
# Beispielnutzung
echo "Verbose mode: $VERBOSE"
echo "File: ${FILE:-<not set>}"
echo "Number: $NUMBER"
echo "Positional arguments: $@"