Last active
February 24, 2025 11:23
-
-
Save goose-ws/1df1b680b6c463076574b62d08e52873 to your computer and use it in GitHub Desktop.
They say if it's more than 100 lines, you should write it in a real language, instead of bash. I say, with enough semicolons, any bash script can be a one line bash script.
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
while IFS= read -r line; do while [[ "${line:0:1}" =~ ($'\t'| ) ]]; do line="${line:1}"; done; if [[ "${line:0:1}" == "#" || -z "${line}" ]]; then continue; fi; if [[ "$line" =~ [^\\#][[:space:]]+# ]]; then line="${line% #*}"; fi; if [[ -n "${line}" ]]; then [[ "$line" =~ \b(do|then)$ ]] && output+="$line " || output+="$line; "; fi; done < "${1}"; output="${output//;;/;}"; echo "${output#;}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made it a one liner, as poetic justice demands