Live data from Hacker News

The bash book to rule them all

fabiensanglard.net

11–20 of 56 posts

Re: The bash book to rule them all

#11

Controversial perhaps, but I now use Go where I used to be a prolific shell script script coder. Main reasons: - Fewer opportunities for foot-guns - Ease of portability, no dependencies, e.g. no more "is jq installed ?" - Consistent cross-platforms, e.g. no more "is this system using GNU sed ?" - Modern stuff like crypto, and "internet stuff" is just quicker and easier to do in Go.

Even more controversial, I use Swift.

Re: The bash book to rule them all

#13

Controversial perhaps, but I now use Go where I used to be a prolific shell script script coder. Main reasons: - Fewer opportunities for foot-guns - Ease of portability, no dependencies, e.g. no more "is jq installed ?" - Consistent cross-platforms, e.g. no more "is this system using GNU sed ?" - Modern stuff like crypto, and "internet stuff" is just quicker and easier to do in Go.

If Go why not something like Python though...?

Re: The bash book to rule them all

#14

> You want to understand why cd is not an executable but a builtin? Because a sub-process cannot change the working directory of its parent. The shell process needs to change its own working directory. Therefore cd must be a builtin. Although, I suppose that one might execve a cd binary, which would change directory and then in turn the cd binary would execve the shell that is specified in the $SHELL env var. That wo…

https://www.skarnet.org/software/execline/execline-cd.html

Re: The bash book to rule them all

#16
post #11

Controversial perhaps, but I now use Go where I used to be a prolific shell script script coder. Main reasons: - Fewer opportunities for foot-guns - Ease of portability, no dependencies, e.g. no more "is jq installed ?" - Consistent cross-platforms, e.g. no more "is this system using GNU sed ?" - Modern stuff like crypto, and "internet stuff" is just quicker and easier to do in Go.

Even more controversial, I use Swift.

swift is so nice to code with

Re: The bash book to rule them all

#17
post #13

Controversial perhaps, but I now use Go where I used to be a prolific shell script script coder. Main reasons: - Fewer opportunities for foot-guns - Ease of portability, no dependencies, e.g. no more "is jq installed ?" - Consistent cross-platforms, e.g. no more "is this system using GNU sed ?" - Modern stuff like crypto, and "internet stuff" is just quicker and easier to do in Go.

If Go why not something like Python though...?

Because Python is godawful for dependencies.

With Go, you write, you compile, you ship the binary, job done.

Re: The bash book to rule them all

#18

$ uname Darwin $ which cd /usr/bin/cd

Huh ? Which OS X are you on ? What you posted is not reproducable on Ventura (13.6) % uname Darwin % which cd cd: shell built-in command

Depends on your shell, if you execute `which -a cd` it will show you /usr/bin/cd in addition to the built-in command.

(zsh has which as a built in command, apparently bash doesn't, which causes the different output). It's unclear to me what /usr/bin/cd actually accomplishes though, even in bash.

(final edit I hope, I found an explanation of sorts for /usr/bin/cd: https://unix.stackexchange.com/a/50060)

Re: The bash book to rule them all

#19
post #13

Earlier quoted context omitted.

If Go why not something like Python though...?

Because Python is godawful for dependencies. With Go, you write, you compile, you ship the binary, job done.

Is Go genuinely as dependency independent as bash on a fresh Linux install? If so I'd find this very interesting and perhaps worthwhile to learn. I work in an environment where everything is done at the Linux command line. I'd be thrilled to re-do some of my my complex bash scripts in Go if there is a good advantage to doing so.
Post reply on HN