Skip to main content
added 23 characters in body
Source Link
jsx97
  • 1.4k
  • 4
  • 25

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 MacPorts, and use something like this:

#!/usr/bin/env bash 

But the env approach is not reliable: what if you run this script on a Mac where only the system bash is installed? Then, env will use bash 3.2 instead (I suppose...), and this will make the script to misbehave and therefore can make harm.

Then, the third approach is

#!/opt/homebrew/bin/bash 

But what if you run this script on a Mac where modern bash is installed using MacPorts instead of Homebrew?

What is the best practice here? (Maybe create a symlink in /usr/local/bin that points to /opt/homebrew/bin/bash, and then #!/usr/local/bin?)

On macOS, #!/bin/bash means a script will use the system bash, which is very dated (3.2, 2006 year) and mostly useless.

Then you can install modern bash using Homebrew or MacPorts, and use something like this:

#!/usr/bin/env bash 

But the env approach is not reliable: what if you run this script on a Mac where only the system bash is installed? Then, env will use bash 3.2 instead (I suppose...), and this will make the script to misbehave and therefore can make harm.

Then, the third approach is

#!/opt/homebrew/bin/bash 

But what if you run this script on a Mac where modern bash is installed using MacPorts instead of Homebrew?

What is the best practice here? (Maybe create a symlink in /usr/local/bin that points to /opt/homebrew/bin/bash, and then #!/usr/local/bin?)

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 MacPorts, and use something like this:

#!/usr/bin/env bash 

But the env approach is not reliable: what if you run this script on a Mac where only the system bash is installed? Then, env will use bash 3.2 instead (I suppose...), and this will make the script to misbehave and therefore can make harm.

Then, the third approach is

#!/opt/homebrew/bin/bash 

But what if you run this script on a Mac where modern bash is installed using MacPorts instead of Homebrew?

What is the best practice here? (Maybe create a symlink in /usr/local/bin that points to /opt/homebrew/bin/bash, and then #!/usr/local/bin?)

Became Hot Network Question
added 60 characters in body
Source Link
jsx97
  • 1.4k
  • 4
  • 25

On macOS, #!/bin/bash means a script will use the system bash, which is very dated (3.2, 2006 year) and mostly useless.

Then you can install modern bash using Homebrew or MacPorts, and use something like this:

#!/usr/bin/env bash 

But the env approach is not reliable: what if you run this script on a Mac where only the system bash is installed, env will use bash 3.2 instead (I suppose...).But the env approach is not reliable: what if you run this script on a Mac where only the system bash is installed? Then, env will use bash 3.2 instead (I suppose...), and this will make the script to misbehave and therefore can make harm.

Then, the third approach is

#!/opt/homebrew/bin/bash 

But what if you run this script on a Mac where modern bash is installed using MacPorts instead of Homebrew?

What is the best practice here? (Maybe create a symlink in /usr/local/bin that points to /opt/homebrew/bin/bash, and then #!/usr/local/bin?)

On macOS, #!/bin/bash means a script will use the system bash, which is very dated (3.2, 2006 year) and mostly useless.

Then you can install modern bash using Homebrew or MacPorts, and use something like this:

#!/usr/bin/env bash 

But the env approach is not reliable: what if you run this script on a Mac where only the system bash is installed, env will use bash 3.2 instead (I suppose...).

Then, the third approach is

#!/opt/homebrew/bin/bash 

But what if you run this script on a Mac where modern bash is installed using MacPorts instead of Homebrew?

What is the best practice here? (Maybe create a symlink in /usr/local/bin that points to /opt/homebrew/bin/bash, and then #!/usr/local/bin?)

On macOS, #!/bin/bash means a script will use the system bash, which is very dated (3.2, 2006 year) and mostly useless.

Then you can install modern bash using Homebrew or MacPorts, and use something like this:

#!/usr/bin/env bash 

But the env approach is not reliable: what if you run this script on a Mac where only the system bash is installed? Then, env will use bash 3.2 instead (I suppose...), and this will make the script to misbehave and therefore can make harm.

Then, the third approach is

#!/opt/homebrew/bin/bash 

But what if you run this script on a Mac where modern bash is installed using MacPorts instead of Homebrew?

What is the best practice here? (Maybe create a symlink in /usr/local/bin that points to /opt/homebrew/bin/bash, and then #!/usr/local/bin?)

Source Link
jsx97
  • 1.4k
  • 4
  • 25

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 mostly useless.

Then you can install modern bash using Homebrew or MacPorts, and use something like this:

#!/usr/bin/env bash 

But the env approach is not reliable: what if you run this script on a Mac where only the system bash is installed, env will use bash 3.2 instead (I suppose...).

Then, the third approach is

#!/opt/homebrew/bin/bash 

But what if you run this script on a Mac where modern bash is installed using MacPorts instead of Homebrew?

What is the best practice here? (Maybe create a symlink in /usr/local/bin that points to /opt/homebrew/bin/bash, and then #!/usr/local/bin?)