mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Subject: Re: [musl] Off topic question about shebang and exec()
Date: Thu, 2 Mar 2023 17:32:22 +0100	[thread overview]
Message-ID: <20230302163222.GI1903@voyager> (raw)
In-Reply-To: <CAKHv7ph5SjxBWVe-XGs81akonQ6oGwwy9JqH1AEcoodRuTwNRw@mail.gmail.com>

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

  reply	other threads:[~2023-03-02 16:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02 14:15 Paul Schutte
2023-03-02 16:32 ` Markus Wichmann [this message]
2023-03-02 17:52   ` A. Wilcox
2023-03-03 11:17     ` [musl] " Valery Ushakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230302163222.GI1903@voyager \
    --to=nullplan@gmx.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).