Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230302163222.GI1903@voyager>
Date: Thu, 2 Mar 2023 17:32:22 +0100
From: Markus Wichmann <nullplan@....net>
To: musl@...ts.openwall.com
Subject: Re: Off topic question about shebang and exec()

On Thu, Mar 02, 2023 at 04:15:38PM +0200, Paul Schutte wrote:
> Hi all
>
> I apologize for abusing the knowledge of the people on this list, but I
> know they will know the answer. Google does not provide a usable answer.
>
> I am busy writing a toy language and I would like it to be used as both a
> compiler and "interpreter"
>
> I would like it to compile the source and then run the resulting binary
> when the source file is called via the shebang and it should just do a
> normal compile when called with "compile code.src"
>
> argv[0] contains the path to the compiler in both cases, which makes sense.
>
> Is there any way to determine which method was used to call the compiler?
>
> Kind Regards
> Paul

Not to my knowledge. I would also consider it poor design to use a trick
like that. The normal assumption is that a shebang and just running the
command from command line are equivalent.

Normal solution here is to have a command line switch to select one
behavior or the other. That switch can be added to the shebang or the
command line, whatever you choose.

Ciao,
Markus

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.