Bash Embedded, OSx vs Linux

I noticed that printf embedded between OSx and Linux does not seem to behave the same. I got the impression that the built-in built-in. This is not related to any specific problem that I am having. I just can't explain it.

OSx

printf '%(+%s)T\n' -2
-bash: printf: `(': invalid format character

which printf
printf is a shell builtin
printf is /usr/bin/printf

Linux

printf '%(+%s)T\n' -2
+1431027100

which printf
printf is a shell builtin
printf is /usr/bin/printf

Some information on how this was tested. On OSx, I use the bash version installed through brew.

OSx Version

bash --version
GNU bash, version 4.3.33(1)-release (x86_64-apple-darwin14.1.1)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

Linux version

bash --version
GNU bash, version 4.3.11(1)-release (i686-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+4
source share
1 answer

%()T- latest addition in bash 4.x; OS X ships bash 3.2 (and is expected to never upgrade to 4.x because Apple refuses to ship licensed GPLv3 software).


bash --version , OS X bash 4, , bash PATH, /bin/bash /usr/bin/bash ( , script shebang .)

bash, bash --version ( bash PATH, ); :

echo $BASH_VERSION

, script bash PATH (, bash, , Apple, - macports homebrew - , ), #!/usr/bin/env bash, #!/bin/bash.

+4
source

All Articles