I'm creating bash scripts with .sh
extensions, performing smiple tasks, but every new script I have to modify with chmod
to run. I see that repositories I download from github/bitbucket containing scripts don't need this and can be run out of the box. How can I achieve this, so when someone download my repository can run this without running chmod +x
first. I'm working on MacOS Big Sur
Asked
Active
Viewed 1,003 times
-1

Erwol
- 15
- 8
-
1You can execute it with `bash script.sh` – Fravadona Jan 18 '22 at 14:01
-
Change your umask so that newly created files are executable. – William Pursell Jan 18 '22 at 14:02
2 Answers
3
I you chmod +x
the file locally, git will see that as a change to the file, and you can push that change so that anybody else who clones the repo has the executable permissions:
chmod +x script.sh
git add script.sh
git commit -m'make script.sh executable'
git push # if you are on a tracking branch
then is will be executable for everybody
I think that is how the repositories that you downloaded accomplished that.

Alex028502
- 3,486
- 2
- 23
- 50
0
usually in unix, simply bash [scrip_name].sh
is enough
In MacOS also, same might be enough

naxoki
- 13
- 4