Last active
October 5, 2015 08:58
-
-
Save putnamhill/2782791 to your computer and use it in GitHub Desktop.
mac shell xtra snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on listReadOnlyVolumes | |
return shell_cmd_list("mount | sed -n 's/^\/dev\/.* on \(\/.*\) (.*read-only.*/\1/p'") | |
end | |
on nonEmptyFolderExists atPosixPath | |
rslt = shell_cmd_list("ls " &qq(atPosixPath) &" 2>/dev/null") | |
return count(rslt) > 0 | |
end | |
on directoryExists atPosixPath | |
return integer(shell_cmd("test -d " &qq(atPosixPath) &" && echo 1 || echo 0")) | |
end | |
-- converts an hfs path to a posix path wrapped in quotes | |
on quotedPosix path | |
return qq(shell_hfs2posix(path)) | |
end | |
-- wraps a string with quotes; reminiscent of perl's qq{} | |
on qq str | |
return QUOTE &str "E | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment