Skip to content

shc not working with ksh 93u+ #13

Closed
@kparcher

Description

@kparcher
uname -a
Linux dove 2.6.32-573.1.1.el6.x86_64 #1 SMP Tue Jul 14 02:46:51 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

ksh --version
  version         sh (AT&T Research) 93u+ 2012-08-01

cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.7 (Santiago)

I compiled a simple ksh shell script with shc (it does not matter which options are used or what the shell script actually does, the result is the same).

./a.out

shll=main
argc=1
argv[0]=./a.out
argv[1]=<null>
getenv(xffffffe4ac74559f)=<null>
shll=/bin/ksh
argc=4
argv[0]=./a.out
argv[1]=-c
argv[2]=exec '*23612*./a.out' "$@"
argv[3]=./a.out
argv[4]=<null>
./a.out: exec: *23612*./a.out: not found

The ksh environment has a strange entry for $_

env

_=*23612*/bin/env
DBPATH=/cms/db/inf
DB_LOCALE=en_us.utf8
G_BROKEN_FILENAMES=1
HISTCONTROL=ignoredups
HISTSIZE=1000
HOME=/root
...

The problem is in the xsh function and here is how I fixed it temporarily:

        //char * me = getenv("_");
        //if (me == NULL) { me = argv[0]; }
        char * me = argv[0];

I am sure there is a better way to fix this permanently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions