1 USING: arrays command-line fry io.launcher kernel math namespaces
2 sequences system unix.ffi ;
5 : apple-script-elevate ( command -- ) 2drop ;
7 GENERIC: glue-command ( prefix command -- glued )
12 M: string glue-command
15 ERROR: elevated-failed path ;
17 HOOK: elevated os ( command win-console? posix-graphical? -- process )
23 nip [ ! graphical (through applescript)
26 f f linux os [ elevated ] with-variable
31 drop ! we are already root: do nothing
33 { "gksudo" "kdesudo" "sudo" } { "sudo" } ? ! graphical handled
34 swap '[ _ glue-command ] map
35 [ " " split [ first utf8 string>alien ] [ rest ] execvp ] map
36 [ -1 = ] all? elevated-failed
39 : elevate ( option? -- ) (command-line) elevated ;
41 HOOK: lowered os ( relaunch? -- )