4 ms·
Does it support eval? Because then you could compile something like #!/usr/bin/env bash eval “$@“ And get a statically compiled bash!
by koolba 2y ago
Does it support eval?
Because then you could compile something like
#!/usr/bin/env bash
eval “$@“
And get a statically compiled bash!
- Imustaskforhelp 2y agoWhat does this do mate? (I tried to run it and it failed)
- mbreese 2y agoYou’d need to pass in arguments… All it does is evaluate the expression you pass in as arguments. ./evalme.sh echo hello world The joke being that if you could transpile this evalme.sh script to a static binary, you’d effectively have a static version of bash itself (transpiled to Go).
- koolba 2y agoIt evaluates the arguments to the command as bash commands. So if you save the file as foo.sh and add it to your PATH. You could run: $ foo.sh 'date ; ls ; foo=bar ; echo "Hello $foo"' Or really anything you'd like as the argument is treated as a bash script. NOTE: The original comment had the #! of the shebang backwards (as !#) due to a typo.