Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symlink available commands to bin #25322

Closed
ob7 opened this issue Apr 29, 2017 · 7 comments
Closed

Symlink available commands to bin #25322

ob7 opened this issue Apr 29, 2017 · 7 comments
Labels
0.kind: question Requests for a specific question to be answered

Comments

@ob7
Copy link
Contributor

ob7 commented Apr 29, 2017

This is another question.

Many times we run commands or write scripts that access common paths in linux, such as /bin/bash.

How can I make nixos automatically symlink all commands to the bin directory?

@bjornfor bjornfor added the 0.kind: question Requests for a specific question to be answered label Apr 29, 2017
@matthewbauer
Copy link
Member

The "Nix" way to do this is to avoid these paths.#!/usr/bin/env $bin should work in all cases.

You definitely can set up a symlink from /bin to /run/current-system/sw/bin but you could also just use the current-system path. Either way though there's probably a better way that doesn't involve hard coding a path.

@ob7
Copy link
Contributor Author

ob7 commented May 8, 2017

So my scrips should say:
#!/user/bin/env $bin/bash instead ???
or just #!/usr/bin/env $bin
no matter if its bash or php or perl or python etc?

@Mic92
Copy link
Member

Mic92 commented May 8, 2017

No, @matthewbauer meant you should place the interpreter inplace of $bin: ex.: #!/usr/bin/env bash, #!/usr/bin/env php or #!/usr/bin/env python

@ob7
Copy link
Contributor Author

ob7 commented May 8, 2017

Thank you

@ob7 ob7 closed this as completed May 8, 2017
@truthadjustr
Copy link

how about #!/usr/bin/env awk -f ???

@Mic92
Copy link
Member

Mic92 commented Oct 23, 2018

$ cat ./foo.awk
#!/usr/bin/env -S awk -f
END { printf "WORKS" }
$ ./foo.awk </dev/null
WORKS

@truthadjustr
Copy link

Thanks. -S now works after updating my coreutils to 8.30. https://stackoverflow.com/questions/1418245/invoking-a-script-which-has-an-awk-shebang-with-parameters-vars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: question Requests for a specific question to be answered
Projects
None yet
Development

No branches or pull requests

5 participants