Bash builtin, OSx vs Linux

I noticed that the printf builtin between OSx and Linux does not appear to behave the same. I was under the impression that a builtin is a builtin. This is not related to any specific issue I am having. I just cant 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 info on how this was tested. On OSx I am using a version of bash installed via 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>

Answers


%()T is a recent addition in bash 4.x; OS X ships bash 3.2 (and is not expected to ever upgrade to 4.x, as Apple refuses to ship software licensed GPLv3).


If bash --version is telling you that your OS X system has bash 4, this is probably a question of checking the version of bash in the PATH, vs the version in /bin/bash or /usr/bin/bash (whichever is used for your script's shebang, or your user account's configured shell).

To check your current version of bash, don't use bash --version (which tells you the version of the first bash interpreter in the PATH, not the version of the current interpreter); instead, use:

echo $BASH_VERSION

If you want to be sure your script uses the first bash interpreter in the PATH (which, if you installed a newer bash than the one Apple provided -- as with macports/a or homebrew/a -- is presumably what you want), use #!/usr/bin/env bash, not #!/bin/bash.


Need Your Help

Azure Service Fabric Cluster connection with on premise network (Private data center)

azure azure-service-fabric

Can you please describe the process on how services inside Service Fabric Cluster could communicate with the database servers present in our private datacenter?

Adding group column to data frame

r

Say I have the following data frame: