Skip to content

Instantly share code, notes, and snippets.

@putnamhill
Last active October 5, 2015 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save putnamhill/2782791 to your computer and use it in GitHub Desktop.
Save putnamhill/2782791 to your computer and use it in GitHub Desktop.
mac shell xtra snippets
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 &QUOTE
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment