Last active
August 29, 2026 11:08
-
-
Save dewomser/31902704b3ab38e8c862b97ef6515181 to your computer and use it in GitHub Desktop.
Shellcheck im Skript aufrufen. Selbstcheck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/bash | |
| # Überprüfen ob Shellcheck installiert ist | |
| if ! command -v shellcheck &> /dev/null; then | |
| echo "Fehler: shellcheck ist nicht installtert. Ausführung wurde abgebrochen." | |
| exit 1 | |
| fi | |
| #Diesese Skript mit Schellcheck prüfen | |
| shellcheck "${0##*/}" | |
| # Variablen | |
| a="hello world" | |
| b="test1" | |
| # ${0##*/} Ist der Name mit Pfad des gerade verwendeten Skripts | |
| echo "$a : ${0##*/}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Wenn man an Bashscripten rumbastelt sollte man immer die Syntax prüfen z.B, mit Shellcheck | |
| Um das nicht zu vergessen, kann man sich diese Zeile Code an den Anfang seines Skripts einbauen. Das Ausführen des Skripts dauert dann etwas länger. | |
| $(which shellcheck) "${0##*/}" | |
| Ausführungszeit kann man noch optimieren in dem man händisch "which shellcheck" ausführt und den ganzen Pfad ins Skript rein pastet.Dann muss Bash nicht suchen wo shellcheck installiert ist. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment