The other day on Twitter, I got a question about a flag for the readlink command that I was not familiar with. As it turns out, the readlink command (which tells you where a symbolic link points to) got an update in macOS 12.3 and now has a -f option. With this new option, readlink will resolve symbolic links anywhere in the path and print the ‘actual’ absolute path to the item. This is equivalent to the realpath command available on Linux and some programming languages.
I have written about this before, and then I mentioned that there is a python function to resolve the path. However, even back then I anticipated the removal of python and suggested using a zsh parameter expansion modifier instead:
resolved_path=${path_var:A}
The removal of Python 2 is the likely explanation for why Apple chose to update readlink in 12.3.
It will be nice to have the new readlink -f option available going forward, but if your script still needs to support versions of macOS older than 12.3 then you should prefer to use the zsh expansion modifier.
More Monterey Command Line Changes?
This was discovered mostly by chance. While Apple’s release notes are improving, there are still nowhere near detailed enough and missing this level of detail, even though that would be amazingly useful.
I remembered that the Kaleidoscope app team had posted a script that allows me to compare man pages between versions of macOS. They published this back when macOS 12 was released to track the changes of the plutil command line tool. With the help of this tool I determined a few more interested changes in macOS 12, the most interesting of which I will summarize here.
(Even with this script, the process was tedious. Many changes to the man pages are just reformatting whitespace and/or typos. I may have missed something. Please, let me know when you find more changes!)
cut
- new
-woption (splits fields on whitespace)
du
- new
-Aoption (apparent size) - new
--sioption (human-readable, in 1000 based units) - new
-toption (only show items over a certain threshold)
aa (Apple Archive)
- new options for encryption
- new
aeacommand for encrypted Apple Archives
tar
- new encryption and compression types
find
- new
-quitprimary - new
-sparseprimary (so you can find APFS sparse files)
grep
- new
rgrep,bzgrep,bzegrep, andbzfgrep - new
--labeloption - new
-M,--lzmaoption
hdituil
segmentsubcommand and Segmented images are deprecatedUDBZdmg format (bzip2 compression) is deprecatedudifrezandudifderezare deprecated (this allows to embed a license in a dmg)
head
- new
-nand-coptions (probably just the man page updated)
killall
- new
-Ioption (confirm) - new
-voption (verbose)
ls
- new
-Doption (date format) - new
whiteoutfile type (no idea what this is? Update: Greg Parker has some insights and more questions)
open
- new
-uoption to open file paths as URLs
pkgbuild
- new
--large-payloadoption - new
--compressionoption - new
--min-os-versionoption
I have an article on the new pkgbuild options.
plutil
- new
-typeoption forextract - new
-rawoption forextract - new
typesubcommand to query type - new
createsubcommand to create a new empty plist
pwd
- new
-poption prints working directory with symbolic links resolved
readlink (12.3)
- new
-foption to resolve symbolic links
rm (12.3)
- new
-Ioption which prompts only when more than three files will be deleted or a directory is being removed recursively
shortcuts
- new command to run, list, or interact with Shortcuts
smbutil
- new
multichannelandsnapshotverbs
Also, the nano command now actually opens pico. (Thanks, @rgov) Most people won’t notice this, as the two are quite similar. The excision of GNU tools from macOS continues.
