491 questions
2 votes
2 answers
126 views
Can't run Python script with ./script.py, but works with python script.py — ICU data error
I'm using VS Code on Windows 10 and have a fresh installation of the latest Python version (downloaded from python.org). I completely removed any older Python installations before reinstalling. When I ...
0 votes
1 answer
81 views
How to prevent unescaped program arguments
This test program parses a single text argument, which could be a URL: #!/usr/bin/env python import argparse def parse_input(): parser = argparse.ArgumentParser( description='Program ...
3 votes
1 answer
210 views
Disable Spell Check for Shebang in Visual Studio Code
With Python primarily being used in virtual environments now, my shebang lines for python scripts can vary depending on the location of the particular virtual environment I'm working in. This causes ...
-2 votes
1 answer
97 views
Avoiding accidental execution of python scripts as bash scripts
I like to run my python scripts directly in bash like so $ ./script.py But sometimes I forget the shebang line #!/usr/bin/env python3, and it has the potential to overwrite a file named np if the ...
-2 votes
1 answer
174 views
Getting VS Code to detect language files with no filename extension without opening them?
I'm trying to standardize some of my bin scripts and i'm going without extensions. However this is proving difficult to see programming language of all my scripts. Some of these are bash, some of ...
0 votes
0 answers
42 views
Shebang ignored? [duplicate]
I don't know how to better title the behaviour I just experienced. I arrived from this answer because I'm trying to read the contents of a file into a string. I have the following script which I made ...
0 votes
2 answers
113 views
Using python interpreter explicitely does not ignore shebang
I have read Does shebang overwrite the python interpreter path, and it seems the given answer does not apply to me. Some context: I am on Windows using C:\Program Files\Git\bin\bash.exe and having two ...
1 vote
1 answer
79 views
Why $BASH_SUBSHELL doesn't work with /bin/bash shebang
Doing some tests, I discovered that setting the bash shebang in a script would cancel the $BASH_SUBSHELL behavior. # in the terminal $ echo $BASH_SUBSHELL 0 $ (echo $BASH_SUBSHELL) 1 ...
0 votes
1 answer
72 views
Can cpp generate a line starting with hash?
This c-preprocessor (cpp) input: #define hash # #define not_hash x hash not_hash produces the following output when run through cpp -P: # x Is there any input to cpp capable of outputting a line ...
0 votes
1 answer
761 views
How to make the shebang use the value of an environment variable
I have a file named kong like this: #!/usr/bin/env /usr/local/openresty/bin/resty setmetatable(_G, nil) pcall(require, "luarocks.loader") package.path = "./?.lua;./?/init.lua;" ....
1 vote
1 answer
61 views
Finding the exact word exist
I just started using dockutil and what to write a script that does the following. Checks if the item exists on the dock. if it doesn't exist add it. if it does do nothing. so do to check if item exist ...
-1 votes
1 answer
63 views
Quitting and restarting
I have this bash script that restarts/monitors myscript while { myscript; rc=$?; true; }; do echo "'myscript' crashed with exit code $rc. Restarting..." >&2 sleep 1 done ...
-1 votes
1 answer
82 views
Python3 shebang -bash: ./main.py: Permission denied
Please actually read my post instead of just the title. This is a larger system issue, not a typo or a file permissions issue. I am attempting to run my script without having to type in 'python3' ...
0 votes
0 answers
157 views
Using ~ in a shebang line
I'm trying to make a runnable Python script with a custom virtual environment. Instead of activating the virtual environment or specifying the full path I tried to use ~ in the shebang line. Does not ...
0 votes
1 answer
187 views
Adding shebang with mac
I want to add a shebang at the beginning of my file.py script using sed in Mac. My file.py starts like this: import os import sys import shutil I have tried: sed -i '.bak' '1 s|^.*$|#!/usr/bin/env ...