neurobin / shc

Shell script compiler
https://neurobin.org/projects/softwares/unix/shc/
GNU General Public License v3.0
2k stars 338 forks source link

Support `#!/usr/bin/env` #21

Open cheecheeo opened 8 years ago

cheecheeo commented 8 years ago

I'm not sure if this is outside the scope of this project, but it would be nice if the #!/usr/bin/env pattern.

% cat bisect.sh
#!/usr/bin/env bash

set -ex

export NIXPKGS=${NIXPKGS:-$HOME/packages/nixpkgs}
nix-env --file "$NIXPKGS" -iA autojump
autojump --help

% shc -U -f bisect.sh
shc Unknown shell (env): specify [-i][-x][-l]
shc: Success
neurobin commented 8 years ago

Please checkout the 3.9.4a branch and report if possible.

cheecheeo commented 8 years ago

@neurobin

% shc -h       
shc Version 3.9.4a, Generic Shell Script Compiler
shc GNU GPL Version 3 Jahidul Hamid <jahidulhamid@yahoo.com>
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-o outfile] [-rvDUCABh] -f script

    -e %s  Expiration date in dd/mm/yyyy format [none]
    -m %s  Message to display upon expiration ["Please contact your provider"]
    -f %s  File name of the script to compile
    -i %s  Inline option for the shell interpreter i.e: -e
    -x %s  eXec command, as a printf format i.e: exec('%s',@ARGV);
    -l %s  Last shell option i.e: --
    -o %s  output filename
    -r     Relax security. Make a redistributable binary
    -v     Verbose compilation
    -D     Switch ON debug exec calls [OFF]
    -U     Make binary untraceable [no]
    -C     Display license and exit
    -A     Display abstract and exit
    -B     Compile for busybox
    -h     Display help and exit

    Environment variables used:
    Name    Default  Usage
    CC      cc       C compiler command
    CFLAGS  <none>   C compiler flags

    Please consult the shc man page.

% shc -U -f bisect.sh

% ./bisect.sh.x      
./bisect.sh.x: invalid option -- 'c'
Try `./bisect.sh.x --help' for more information.
neurobin commented 7 years ago

Currently there is no plan to add this feature.

intika commented 5 years ago

Can you please check the current version with the H flag and report back

evils commented 4 years ago

@intika 4.0.3 has this with and without -H

Hayao0819 commented 3 years ago

I'm running into a similar problem.I want to support env.

felipecrs commented 3 years ago

How to work around it in the command line?

shc -x /bin/bash does not help

leowill01 commented 2 years ago

This would be very useful because if I'm not mistaken, the compiled script is at the mercy of whatever version of the shebang shell the operator has on their system and not the version the script was developed with. I guess one could add a check for the version of /usr/bin/bash being used, but this would still be a useful option to have.