Skip to content

Instantly share code, notes, and snippets.

@T1T4N
Last active December 14, 2016 08:49
Show Gist options
  • Save T1T4N/01f5aa904e07c53c0513993c418c43bf to your computer and use it in GitHub Desktop.
Save T1T4N/01f5aa904e07c53c0513993c418c43bf to your computer and use it in GitHub Desktop.
gksudo implementation for macOS
#!/usr/bin/osascript
on convertListToString(theList, theDelimiter)
set output to (item 1 of theList)
if (count theList) > 1 then
set theList to items 2 through (count theList) of theList
repeat with listItem in theList
set parsedItem to listItem
if space is in listItem then
set parsedItem to (quoted form of listItem)
end if
set output to output & theDelimiter & (parsedItem)
end repeat
end if
return output
end convertListToString
on run argv
if (count argv) < 1 then
log "Script is missing arguments"
error
end if
set parsedCommand to convertListToString(argv, space)
log "Running command: " & parsedCommand
set ret to (do shell script parsedCommand with administrator privileges without altering line endings)
return ret
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment