Scripting OS X

scriptingosx.com · Personal blog · on HN since 2019

Armin Briegel, a Mac admin and developer, writes about shell scripting, command line tools, and automation on macOS.

What HN saysCommenters call it a great resource and cite it for details on zsh, bash, sh and dash in macOS, plus the open command and a Swift tool example.
16HN people shared it
10linked it in comments
8stories submitted
185story points
1 year agolast shared
2019people per year2026

Most-shared posts

  1. 1
  2. 2
    Moving to zsh (2019)
    2 people · 57 points · first shared 2022 · 41 comments on HN
  3. 3
    Notarize a command line tool
    2 people · first shared 2020
  4. 4
    The unexpected return of JavaScript for automation
    1 people · 73 points · first shared 2021 · 28 comments on HN
  5. 5
    On env Shebangs
    1 people · 47 points · first shared 2022 · 32 comments on HN
  6. 6
    On viewing man pages (Ventura update)
    1 people · 3 points · first shared 2022 · discussion on HN
  7. 7
    Moving to zsh
    1 people · 2 points · first shared 2019 · discussion on HN
  8. 8
    Downgrading a Mac That Shipped with Catalina to Mojave
    1 people · 1 points · first shared 2020 · discussion on HN
  9. 9
    An AirTag Adventure, Part 2–Receiving an AirTag
    1 people · 1 points · first shared 2021 · discussion on HN
  10. 10
  11. 11
    The macos open command
    1 people · first shared 2023
  12. 12
    Macos 11
    1 people · first shared 2023
  13. 13
    Editing property lists
    1 people · first shared 2023
  14. 14
    Homepage
    1 people · first shared 2022

What HN people wrote when they linked it

lelandfe · 2022-05-05
scriptingosx[0] is a great resource, here's a simple Swift command line tool they wrote that might be a good reference: https://github.com/scriptingosx/desktoppr [0] https://scriptingosx.com/
nier · 2023-01-14
In ten years everything will be the same because Andreas Wendker told us that Macs will stay Macs the way we know and love them. He’s neither in marketing nor in sales but an engineer so obviously what he says must be the truth, to put it sarcastically. «Macs will stay Macs the way you know and love them. They will run the same powerful Pro apps. They will offer the same developer APIs Macs have today. They will let users create multiple volumes on disks with different operating system versions and they will let users boot from external drives. They will support drivers for peripherals and they will be amazing UNIX machines for developers and the scientific community that can run any software they like.» Source: https://scriptingosx.com/2020/06/macos-11/
throw0101b · 2023-08-09
> bash was written a decade prior to standardization, and has interesting issues because of this. bash can do whatever it wants to do if it's called as "bash". But it should only do specific things when called as "sh". This is true of any shell: > When interpreted with dash instead of bash, the same script will fail. This is because dash is much stricter than bash in following the sh standard. Since dash is designed as a minimal implementation of the sh standard, it has to be stricter. The double brackets [[ … ]] are a ‘bashism,’ or a feature only available in bash and other, later shells such as ksh and zsh. > Even though zsh also interprets most of these bashisms, zsh in sh compatibility mode is also stricter than bash and will error. * https://scriptingosx.com/2020/06/about-bash-zsh-sh-and-dash-in-macos-c… * https://zsh.sourceforge.io/Doc/Release/Invocation.html#Compatibility POSIX.2: Shell and Utilities (IEEE Std 1003.2-1992) is a few decades old now: regardless of when bash development started, I would think that by the 2010s it would have managed to better compartmentalize compatibility and extensions.
foldr · 2024-04-30
Apple added /bin/dash in Catalina, and the intention is probably to eventually to use dash as the implementation of sh: https://scriptingosx.com/2020/06/about-bash-zsh-sh-and-dash-in-macos-c… As for why they haven't done it yet, I'd guess it's just to preserve backward compatibility with old scripts that rely on quirks of bash's sh compatibility mode.
wsc981 · 2023-12-14
A nice thing about Apple’s Terminal is the open [0] command. I miss that in Windows Powershell and would likely miss it in Linux as well. ——— [0]: https://scriptingosx.com/2017/02/the-macos-open-command/
dcow · 2023-06-27
I’m surprised TFA doesn’t mention `plutil` and its counterpart `PlistBuddy`. They’re like the `jq` of macOS. https://scriptingosx.com/2016/11/editing-property-lists/
JimDabell · 2022-01-28
> Will they completely remove bash, rsync, eventually? Removing bash is a pretty safe bet. They’ve been making move after move in recent years preparing for it. https://scriptingosx.com/2019/06/moving-to-zsh/
floatingatoll · 2020-07-29
This error occurs on default macOS when using software precompiled on another computer, when the person who compiled and released that software has not signed up for an Apple Developer account and submitted the precompiled bundle for notarization, one of Apple's anti-malware prevention mechanisms. https://developer.apple.com/documentation/xcode/notarizing_macos_softw… You can usually work around it by right-clicking the app and choosing Open, which usually triggers a special approval dialog. You should generally use caution when doing so, as you're granting an arbitrary binary whose contents you are unlikely to verify access to your private data. ps. Developers, automating this process as part of your releasing is relatively easy, assuming you have a paid Developer account. The shell script at this link is accompanied by a clear walkthrough, and can be adapted to most workflows run locally on a machine containing your signing keypair. (And if your precompiled binary or bundle was not built with Xcode, you would skip the “xcodebuild” step.) https://scriptingosx.com/2019/09/notarize-a-command-line-tool/
1vuio0pswjnm7 · 2025-06-10
"bash, obviously for scripting;" It's possible to use bash for both interactive use and scripting. For example, this author claims to use bash as his scripting shell. But Debian and the popular Debian-derived distributions do not use bash for scripts beginning with "#!/bin/sh", i.e., "shell scripts". The interactive shell may be bash, but the scripting shell, /bin/sh, is not bash. https://www.man7.org/linux/man-pages/man1/dash.1.html https://wiki.ubuntu.com/DashAsBinSh https://wiki.archlinux.org/title/Dash https://www.oreilly.com/library/view/shell-scripting-expert/9781118166… ^1 https://www.baeldung.com/linux/dash-vs-bash-performance https://en.wikipedia.org/wiki/Almquist_shell https://lwn.net/Articles/343924/ https://scriptingosx.com/2020/06/about-bash-zsh-sh-and-dash-in-macos-c… ^2 I use an Almquist shell, not bash, for both interactive use and scripting. I often write scripts interactively. I use the same scripts on Linux and BSD. I restored tabcomplete and the fc builtin to dash so it feels more like the shell from which it was derived: NetBSD sh. 1. "This makes it smaller, lighter and faster than bash." 2. "... this is strong indicator that Apple eventually wants to use dash as the interpreter for sh scripts."

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close