-
-
Save janmalec/118463af534e17796a2ae69c4638a48a to your computer and use it in GitHub Desktop.
Simple converter from batch (.bat) files to shell script (.sh)
This file contains 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/env bash | |
# | |
# Converts Windows batch script to Linux shell script | |
# | |
# Invocation: | |
# ./bat2sh script.bat | |
# | |
OUTFILE=${2:-${1%%.bat}.sh} | |
cat "$1" | \ | |
sed \ | |
-e 's/\bset\b/export/g' \ | |
-e 's/%\([^/]\+\)%/${\1}/g' \ | |
-e 's/^call.*$//g' \ | |
-e 's/\r//' \ | |
> "$OUTFILE" | |
chmod a+x "$OUTFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment