![]() The parenthesis syntax is more readable and can be nested. In general, it is a good rule to always quote literal strings. Combining literal strings with special characters Whether you should use double quotes or single quotes depends on the use case. Things can start getting complicated when you want special characters with their special functionality. For example, when you want to refer to the path ~/Library/Application Support, you should put it in quotes, because of the space. But when you put the ~ in the quotes, it will not be substituted to the user’s home directory path. There are a few ways to solve this problem. You could escape the space with a backslash. But the easiest is to move the special character out of the quotes: dirpath=~"/Library/Application Support" You could use the $HOME variable instead (but be sure you are in a context where this is set). A common situation for MacAdmins is the following osascript: osascript -e 'display dialog "Hello, World"' Sometimes it is necessary to have a set of quotes within quotes. The osascript command can be used to run Apple commands or scripts. Since AppleScript uses double quotes for literal strings, the entire AppleScript command is passed in single quotes. This works fine, until you want to do something like this: computerName=$(scutil -get ComputerName) This keep the command string together and the double quotes in single quotes don’t confuse the shell. NewName=$(osascript -e 'text returned of (display dialog "Enter Computer Name" default answer "$computerName")')Īgain, we put the AppleScript command in single quotes, so we can use double quotes inside. There are a few solutions out of this, I will demonstrate three:įirst, you could close the single quotes before the variable substitution and re-open them after: osascript -e 'text returned of (display dialog "Enter Computer Name" default answer "'$computerName'")' But now, the single quotes are also blocking the variable substitution and we get the literal $computerName in the dialog. This will in this form as long as $computerName contains no spaces. This is unlikely as the default computer name is something like Armin's MacBook Pro. We can avoid that by putting the substitution itself in double quotes: osascript -e 'text returned of (display dialog "Enter Computer Name" default answer "'"$computerName"'")' The shell will consider that space a separator before a new argument, breaking the AppleScript command into meaningless pieces and failing the osascript command. This works and is entirely legal syntax, but not very legible. If you need the same Geeklet on your secondary screen home, and on your secondary screen at work for example, you will have to create the same Geeklet for both.But then we have to deal with the double quotes required for the AppleScript string literal.Įscaping the escape charactersĪnother solution is to use double quotes for the entire AppleScript command, we can use variable substitution inside. Which means that the old behavior of having Geeklets positioned out of screen pounds relative to the main screen is no longer valid. Important! Now that geeklets are placed relative to their screen, if the screen is not present, geeklets won't be opened. Implemented geeklet placement relative to their screen.Fix a bug causing inconsistent behavior of geeklets when duplicating them.Fix a bug with Geeklet disappearing when screen configuration changes.Fix a bug causing locking of GeekTool Helper when running long scripts.Fix a bug causing Geeklets to disappear on some MacBook Pro computers.GeekTool can now load plugins from user's directory (see documentation).Added an actionable warning sign in the settings palette when the geeklet is not visible.Geeklets script now shows output of timed out scripts.Fix a bug causing Web geeklet to crash GeekTool with some web pages.Fix a bug that caused GeekTool Helper to crash if an incorrect regular expression was set in the File Geeklet settings.Fixed a memory leak when shell geeklets are cancelled.GeekTool crash when screen configuration changed under some circumstances.Geektool Helper crashes on malformed ANSI coloring sequencing.Fix a bug causing GeekTool processes to miss their name in Activity Monitor.Better management of multiscreen configurations.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |