date -R in El Capitan - bash

I'm trying to include a date flag "date -R" in a bash script to use RFC 2822 and the script works fine in macOS 10.12 but not in Mac OS X 10.11. I get an illegal option.
I checked the man pages for date and the date -R flag seems to be available in 10.12 but not in 10.11 even though both systems are running the same version of bash.
Any idea of why there would be a difference or any work arounds? We're testing -u to use a universal time code but my main concern is non-english unicode characters.
We're trying to to convert non-English Unicode characters in CSV files and timestamps keep showing up as issues.

Related

Why date '+%s%N' not working on mac terminal?

I am working on bash scripts on both linux and mac.
I run this command on remote server with linux OS and it just work perfect.
CURRENT_TIME=$(date '+%s%N')
echo "$CURRENT_TIME"
However, when I run the same command on mac terminal, it shows this error:
1654778186N: value too great for base (error token is "1654778186N")
It look like mac terminal did not recognized the '%N'. What should I do to fix the issue on mac terminal?
%N is a GNU extension to the POSIX standard, as clarified in GNU's own documentation: https://www.gnu.org/software/coreutils/manual/html_node/Time-conversion-specifiers.html
The POSIX version of date, doesn't include %N: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html
If I recall correctly, POSIX-certified systems (and macOS is certified) cannot add custom extensions to POSIX tools to guarantee portability across systems.

Mac OS terminal script file variables (.command)

I'm fairly new to writing scripts on Mac OS so apologies if the answer is fairly obvious.
I want to add a date variable to my script on Mac OS that will output the current date in YYYYMMDD format.
On Windows I would write this as:
set now=%date:~6,4%%date:~3,2%%date:~0,2%
%now%
How would I do something similar when writing a .command file on Mac OS?
You can run this in a terminal/bash script
myDate=$(date +%F)
echo $myDate
It outputs a date like:
2021-05-21
Alternatively you can specify a formatter:
myDate=$(date +%Y%m%d) # to remove the dashes
Starting in bash 4.1 or 4.2, the builtin printf can emit the formatted time:
printf '%(%Y%m%d)T' -1 # => 20210521
Since MacOS ships with bash 3.2 by default that means you'll need to install a newer version yourself. With Homebrew that is as easy as brew install bash

How can I install es_AR locale on OSX El Capitan?

I'm trying to install a locale on OSX (El Capitan) and I can't figure it out.
I've been googling for hours now.
In Ubuntu is as simple as locale-gen and dpkg-reconfigure.
I'm coding a PHP application that uses es_AR as a locale and I can't get my number formatting right.
Works fine in Linux systems.
Thanks.
First off, you already have asked this question here, and the Apple or Unix/Linux StackExchange pages are more appropriate for this question, however you put up bounty, and if nobody answers your question you don't get that bounty back, so I'll answer here and follow up with the same answer (if you find it formidable) on that other page.
Unfortunately Apple really did not create a locale for Argentina, so when you look at the Language & Region section in the OSX settings, the difference between Español (Spain) and Español (Latinoamérica) is really non-existent in OSX. When I enabled either, there was no change on the available locales on my system:
$ locale -a | grep es
es_ES
es_ES.ISO8859-1
es_ES.ISO8859-15
es_ES.UTF-8
So unfortunately Apple did not include the es_419 (Latin America) or es_AR (Argentina) locales, and they tied those up into the es_ES locale.
In talking to a friend who travels to Argentina frequently, is fluent in Spanish and also uses Spanish on their Mac:
There could be slight spelling differences but mostly it's the grammar. It would just be some Spain Spanish grammar, but Argentines use some variants of Spain conjugations.
So really it should not matter in the long run. You can simply copy the locale on Mac to match the naming:
sudo cp -R /usr/share/locale/es_ES /usr/share/locale/es_AR
Also I checked on a few of my Linux hosts, and the sha256 sum for these locales are the same, so it looks like the Linux developers have done the same exact thing that Apple has basically done.
$ sha256sum /usr/share/locale/es_ES/LC_MESSAGES/libvisual-0.4.mo
20848a8a8d6ddca454825b3b4102393699850d156d7157535850556e110fb891
$ sha256sum /usr/share/locale/es_AR/LC_MESSAGES/libvisual-0.4.mo
20848a8a8d6ddca454825b3b4102393699850d156d7157535850556e110fb891

How to override -F option on ls command under Mac OSX

Generally I like the -F option - it quickly shows you what is a directory, what is executable etc. But it seems to be permanently on under Mac OS X (using the default ls command under 10.6.8 - I haven't installed GNU or anything). This prevents the output being filtered to another command that expects file names without the appended characters.
How do I change this behaviour?
thanks

Emacs limits number of characters pasted from system clipboard?

I'm running GNU Emacs 23.1.1 on Mac OS X 10.5.8.
If I copy a long string of text into system clipboard (with cmd+c) and paste it into emacs (with cmd+v) only the first 4095 (2^12) characters are pasted.
It's not a terminal quirk, as I tried it on both iTerm and standard mac term with identical results. And if I try this in vim paste works as expected. So it must be an emacs issue.
Is there a variable like max-sys-clipboard-size that I can increase so emacs will paste the the copied text in its entirety?
I had a similar issue using paste from a tmux paste-buffer. I was using emacs 23.2 (latest stable) on linux.
To resolve it, I upgraded to the latest development version using trunk of the bazaar repository. Under emacs 24.0.50.1, this appears to longer be a problem.
For the record, I don't believe there is a max clipboard paste limit within emacs and I think it must have been a bug of some sort.

Resources