In my reading today I came across several references to shebangs From the references I've found it looks like a shebang is a way to make hard path reference to an executable like bash. Is this right or have I missed something? I thought people were trying to get hard coded paths out of their code.
Have a Great Day!
Pat (tablepc)
On 2/8/19 1:56 PM, pmkellly@frontier.com wrote:
In my reading today I came across several references to shebangs From the references I've found it looks like a shebang is a way to make hard path reference to an executable like bash. Is this right or have I missed something? I thought people were trying to get hard coded paths out of their code.
https://en.wikipedia.org/wiki/Shebang_(Unix) The "#!" line at the start of a script that tells the OS what program to use to run it.
I'd you're not sure the path of something you do have the option of using #! /bin/env python As an example so you don't require the entire path
On Fri, Feb 8, 2019, 17:06 Samuel Sieb samuel@sieb.net wrote:
On 2/8/19 1:56 PM, pmkellly@frontier.com wrote:
In my reading today I came across several references to shebangs From the references I've found it looks like a shebang is a way to make hard path reference to an executable like bash. Is this right or have I missed something? I thought people were trying to get hard coded paths out of their code.
https://en.wikipedia.org/wiki/Shebang_(Unix) The "#!" line at the start of a script that tells the OS what program to use to run it. _______________________________________________ test mailing list -- test@lists.fedoraproject.org To unsubscribe send an email to test-leave@lists.fedoraproject.org Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/test@lists.fedoraproject.org
On Fri, Feb 08, 2019 at 04:56:12PM -0500, pmkellly@frontier.com wrote:
looks like a shebang is a way to make hard path reference to an executable like bash. Is this right or have I missed something?
You missed something. Samuel Sieb already replied with reference. You may use it like
#!/usr/bin/env bash
which will look for bash in your PATH and similar with other interpreters.
I thought people were trying to get hard coded paths out of their code.
Usually you DO NOT want to execute a program called 'bash' found somewhere instead of /bin/bash. A script writer does not control what will be found first in PATH.
Besides in the above you need '#!/usr/bin/env' as kernel knows nothing about PATH. You can more often encounter '#!/usr/bin/env python' or something like that; this give more flexibility which 'python' to use with trade-offs involved.
Michal
On Fri, Feb 08, 2019 at 04:39:27PM -0700, Michal Jaegermann wrote:
On Fri, Feb 08, 2019 at 04:56:12PM -0500, pmkellly@frontier.com wrote:
looks like a shebang is a way to make hard path reference to an executable like bash. Is this right or have I missed something?
You missed something. Samuel Sieb already replied with reference. You may use it like
#!/usr/bin/env bash
which will look for bash in your PATH and similar with other interpreters.
I thought people were trying to get hard coded paths out of their code.
Usually you DO NOT want to execute a program called 'bash' found somewhere instead of /bin/bash. A script writer does not control what will be found first in PATH.
Besides in the above you need '#!/usr/bin/env' as kernel knows nothing about PATH. You can more often encounter '#!/usr/bin/env python' or something like that; this give more flexibility which 'python' to use with trade-offs involved.
Current Fedora packaging guidelines prohibit using tricks like #!/usr/bin/env perl, instead requiring #!/usr/bin/perl hardcoded paths for all scripts packaged and distributed with Fedora. In fact, the build process will fixup script shebang lines automatically.
https://pagure.io/packaging-committee/issue/700
https://docs.fedoraproject.org/en-US/packaging-guidelines/#_shebang_lines