cweber105 cweber105 - 1 month ago 15
Bash Question

Do all applications have a command line interface?

I've been learning shell script on my Mac recently. Take an application like Atlassian's SourceTree as an example. My understanding is that it's just a GUI for git commands, which can be executed through command line. Pressing a button just triggers a corresponding git command, which is effectively run through the command line behind the scenes. If that is the case, do all applications that have a GUI function this way? Are all applications essentially just running their commands through the machine's shell script? And if so, are the underlying commands that are being used publicly available, offering an API of sorts for any application?

Answer

This is more complex than that.

Many applications only have a GUI (e.g., Safari), many others only have a CLI (e.g., find).

When a GUI app and a CLI app perform the same function, they may communicate with each other or they may not:

  • As you point out a GUI application can run a CLI command behind the scene (with system() or popen() for instance)

  • An alternative is that both applications use the same underlying library

  • Or no code is shared at all (think of ls vs. Finder on Mac)

  • Finally on Mac some GUI apps can be controlled with Applescript language, which is available through osascript command. In other words, you can control iTunes with a bash script.

Comments