Reputation: 585
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?
Upvotes: 1
Views: 843
Reputation: 67869
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.
Upvotes: 3
Reputation: 1
Definitely, not all applications behave that way. In fact, from my experience, I'd say that there are few applications that follow that. Most applications perform their own operations relying directly on the OS platform and functionalities, instead of executing shell commands which, in addition, are hard (and most of the time impossible) to port between OSs.
Upvotes: 0