shc icon indicating copy to clipboard operation
shc copied to clipboard

Support `#!/usr/bin/env`

Open cheecheeo opened this issue 9 years ago • 8 comments

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

cheecheeo avatar Aug 11 '16 21:08 cheecheeo

Please checkout the 3.9.4a branch and report if possible.

neurobin avatar Aug 11 '16 23:08 neurobin

@neurobin

% shc -h       
shc Version 3.9.4a, Generic Shell Script Compiler
shc GNU GPL Version 3 Jahidul Hamid <[email protected]>
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.

cheecheeo avatar Aug 12 '16 00:08 cheecheeo

Currently there is no plan to add this feature.

neurobin avatar Aug 26 '17 17:08 neurobin

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

intika avatar Nov 12 '18 18:11 intika

@intika 4.0.3 has this with and without -H

evils avatar Jan 25 '20 04:01 evils

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

Hayao0819 avatar Jan 04 '21 04:01 Hayao0819

How to work around it in the command line?

shc -x /bin/bash does not help

felipecrs avatar Jan 04 '21 23:01 felipecrs

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.

leowill01 avatar Dec 13 '21 17:12 leowill01