Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 931667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:32:34+00:00 2026-05-15T20:32:34+00:00

What is the accepted, portable way to include interpreter options in the shebang line,

  • 0

What is the accepted, portable way to include interpreter options in the shebang line, ie. how can I do something like

#!/usr/bin/env  python -c 

or (more importantly) something like

#!/usr/bin/env java -cp "./jars/*:./src" -Xmn1G -Xms1G -server

and get it to be parsed correctly? Right now ubuntu seems to just glom the whole thing together, although other systems will parse this with no problem.

http://en.wikipedia.org/wiki/Shebang_%28Unix%29

describes the problem but offers no solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:32:35+00:00Added an answer on May 15, 2026 at 8:32 pm

    There’s no good solution, as different unices treat multi-word #! lines differently. Portable #! use limits you to at most one argument to the interpreter on the #! line, and no whitespace in the interpreter or argument.

    If the language allows it, you can make the script a shell script which takes care of loading the interpreter with whatever command line it likes. For example, in Perl, from the perl manual:

    #!/bin/sh -- # -*- perl -*- -p
    eval 'exec perl -wS "$0" ${1+"$@"}'
    if $running_under_some_shell;
    

    The shell stops processing after the second line, and Perl sees lines 2–3 as an instruction that does nothing. Some lisp/scheme dialects make #!…!# a comment, allowing you to write

    #!/bin/sh
    exec guile -s "$0" "$@"
    !# ;; scheme code starts here
    

    In general, the only solutions involve two files. You can write #!/usr/bin/env mywrapper where mywrapper is a program (it can be a script) that calls the actual interpreter with whatever argument it wants. Or you can make the executable itself the wrapper script and keep the interpreted file separate. The second solution has the advantage of working even if the interpreter doesn’t accept a leading #! line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an accepted way of performing (pinch) zoom on a view that is
Following method is accepted if I set UIColor like: [tabBarController.tabBar setSelectedImageTintColor:[UIColor greenColor]]; However I
In the accepted answer on my earlier question ( What is the fastest way
Is there an accepted way to represent high resolution timestamps in JSON and/or JavaScript?
In reference to the accepted solution in: SO:expression_evaluator Can anyone provide a version that
The accepted answer to How to convert a Some( ) to None in one-line?
The accepted answer to sql swap primary key values fails with the error Can't
The accepted answer to boost::python Export Custom Exception shows how to export a custom
What is the generally accepted way to implement the main loop of a server
As described in the accepted answer to Most pythonic way of accepting arguments using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.