Questions tagged [shebang]
Use the tag /shebang if your question is about `#!`-string at the beginning of a script
136 questions
0
votes
0
answers
41
views
User can't execute a shell script based on shebang but ok when interpreter directly invoked [duplicate]
Context
I have a system user caddy and a shell script placed under /run/caddy/caddy-cert-obtained-wrapper.sh.
/run and /run/caddy are owned by root:root with permissions 0755.
caddy-cert-obtained-...
13
votes
1
answer
2k
views
Shebang apparently calls wrong shell
I am currently relearning a few basics about shell scripts and encountered the following problem.
I have the following script error.sh
#!/usr/bin/env bash
n=$(( RANDOM % 100 ))
if [[ n -eq 42 ]]; ...
-3
votes
2
answers
255
views
Is Bourne shell shebang #!/bin/sh expecting BASH POSIX-correct? [closed]
I've recently been playing with the legacy Bourne Shell from the GitHub repo heirloom-sh. It's installed at /usr/local/bin/sh with no symlinks. One script is invoking it via #!/bin/env sh.
I'm running ...
0
votes
0
answers
32
views
What are the rules behind finding executables in shebang statements? [duplicate]
I want to create a Docker image that has the Python3 runtime, a Python script of my creation, update-alternatives configured to run python3 when python is invoked, and I want to make the Python script ...
2
votes
2
answers
2k
views
bash shebang on macOS
On macOS, #!/bin/bash means a script will use the system bash, which is very dated (3.2, 2006 year) and (for myself, at least) mostly useless.
Then you can install modern bash using Homebrew or ...
1
vote
1
answer
150
views
shell-expand-line and shebangs
In bash, the very useful shell-expand-line (M-C-e) expands command substitutions to their contents, on the current line. However, this works very strangely for commands without shebangs.
One may ...
14
votes
1
answer
2k
views
Shebang can reference a script in Linux
I've always heard that the target of a shebang line (e.g. #!/bin/bash) must be a binary executable, not a script. And this is still true for many OSes (e.g. MacOS). But I was surprised to see that ...
9
votes
1
answer
2k
views
Why does env -S with quoted strings in the shebang line work fine in Ubuntu but not in macOS?
I have the following script in an executable file test-shebang.mjs and I wanted to use zx to run my script but have my ~/.zshrc be sourced before that:
#!/usr/bin/env -S zsh -c 'source ~/.zshrc; zx --...
0
votes
0
answers
81
views
Unable to mount from a script using shebang (kernel hardening related ?)
I stumbled across a really weird issue with mount. I'm unable to make sense out of it.
For some context, I wrote a Python script that aims to automount hot-pluggable USB devices, but this is not ...
1
vote
0
answers
2k
views
How can I run the file currently open in the kate editor as a python script?
I am writing Python scripts and using a shebang line to specify the location of the Python interpreter in my system.:
#!/usr/bin/env python
So, in principle, my system should be able to run the ...
1
vote
0
answers
157
views
How does the system decide which shell runs a script without a shebang line? [duplicate]
I have this "script" on my Arch Linux system:
$ cat ~/scripts/foo.sh
ps -hp $$
It will simply run ps on its own PID. But the script has no shebang line. I was expecting that in the absence ...
1
vote
2
answers
788
views
Is there a Guix equivalent of nix-shell shebangs?
I want to write a script which executes within a specific guix shell environment. I'm hoping there's an equivalent version of the nix-shell shebang. For example, it would be cool to write something ...
4
votes
1
answer
1k
views
Why don't we use #!command for the shebang line?
#!python3
print("Hello")
I find that this code works fine in my terminal. But everyone does #!/path/to/file or #!/usr/bin/env command.
Is there any reason to avoid using #!command in ...
5
votes
1
answer
2k
views
How to make a Makefile executable?
I have a Makefile, and I want make to run automatically when I double-click it (from the Ubuntu file manager). So, I made this Makefile executable, and added at its top the following shebang line:
#!/...
2
votes
2
answers
436
views
Do executable shebang scripts always require LF line endings?
On Stack Overflow a comment to Can PowerShell Core handle ps1 files with CRLF line endings in Linux environments? asserted that executable files that use a shebang must use only the LF line ending, ...