Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BitPuffin/d9fe27734c0e09bf6e4d3c62fe40c816 to your computer and use it in GitHub Desktop.
Save BitPuffin/d9fe27734c0e09bf6e4d3c62fe40c816 to your computer and use it in GitHub Desktop.
Bash & Batch / Bat Polyglot template and Argument shim
a1 = a1;
a2 = a2;
a3 = a3;
a4 = a4;
a5 = a5;
a6 = a6;
a7 = a7;
a8 = a8;
a9 = a9;
bash("a1=\"$1\"");
bash("a2=\"$2\"");
bash("a3=\"$3\"");
bash("a4=\"$4\"");
bash("a5=\"$5\"");
bash("a6=\"$6\"");
bash("a7=\"$7\"");
bash("a8=\"$8\"");
bash("a9=\"$9\"");
batch("set a1=%1");
batch("set a2=%2");
batch("set a3=%3");
batch("set a4=%4");
batch("set a5=%5");
batch("set a6=%6");
batch("set a7=%7");
batch("set a8=%8");
batch("set a9=%9");
p = p;
batch("set p=\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\"");
bash("p=\"C:\\Program Files\\Sublime Text 3\\sublime_text.exe\"");
call(p, a1, a2, a3, a4, a5, a6, a7, a8, a9);
echo off
echo ; set +v # > NUL
echo ; function GOTO { true; } # > NUL
GOTO WIN
# Bash start
a1="$a1"
a2="$a2"
a3="$a3"
a4="$a4"
a5="$a5"
a6="$a6"
a7="$a7"
a8="$a8"
a9="$a9"
a1="$1"
a2="$2"
a3="$3"
a4="$4"
a5="$5"
a6="$6"
a7="$7"
a8="$8"
a9="$9"
p="$p"
p="C:\Program Files\Sublime Text 3\sublime_text.exe"
"$p" "$a1" "$a2" "$a3" "$a4" "$a5" "$a6" "$a7" "$a8" "$a9"
# Bash end
exit 0
:WIN
REM Batch start
@echo off
setlocal EnableDelayedExpansion
setlocal EnableExtensions
set a1=!a1!
set a2=!a2!
set a3=!a3!
set a4=!a4!
set a5=!a5!
set a6=!a6!
set a7=!a7!
set a8=!a8!
set a9=!a9!
set a1=%1
set a2=%2
set a3=%3
set a4=%4
set a5=%5
set a6=%6
set a7=%7
set a8=%8
set a9=%9
set p=!p!
set p="C:\Program Files\Sublime Text 3\sublime_text.exe"
!p! !a1! !a2! !a3! !a4! !a5! !a6! !a7! !a8! !a9!
REM Batch end
echo off
echo ; set +v # > NUL
echo ; function GOTO { true; } # > NUL
GOTO WIN
# Bash start
# Bash end
exit 0
:WIN
REM Batch start
REM Batch end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment