This version of AuthorizationShell was pulled directly out of Feedback. This version is based on the work done by Tim Jones and Jonathan Johnson. Unfortunately, I am not aware what changes I made to it, but I do know I made some kind of changes.

The shell is used to install the updated Feedback app. Feedback first writes an installer script to disk, then uses the shell to execute it. Gotcha: script cannot be in the temporary directory.

Here is the relevant code from Feedback. Some of the variables such as "this" and "pid" are defined elsewhere, but that is not important, as this code is only meant to demonstrate a concept.

    // to make this happen, we need to create an installer script first
    dim script,eol as string
    eol = endofline.unix
    script = "#!/bin/sh" + eol + eol
    script = script + "/bin/mv " + this.shellpath + " " + specialfolder.trash.child(movedname).shellpath + ";" + eol
    script = script + "/bin/cp -R " + file.shellpath + " " + parent.shellpath + ";" + eol
    script = script + "/bin/kill " + format(pid,"-0") + ";" + eol
    script = script + "/usr/bin/touch " + parent.child(file.name).shellpath + ";" + eol
    script = script + "/usr/bin/open " + parent.child(file.name).shellpath + ";" + eol
    script = script + "exit 0;"
    
    dim script_file as folderitem = specialfolder.userhome.child(".ukinstaller.sh")
    dim t as textoutputstream = script_file.createtextfile
    if t = nil then
      // should have some kind of error notice here
      return
    end
    t.write script
    t.close
    
    // and make sure its executable
    dim sh as new shell
    sh.mode = 0
    sh.execute "/bin/chmod 755 " + script_file.shellpath
    
    // now we're ready to execute it
    dim authshell as new authorizationshell
    dim r as boolean
    dim args(0) as string
    args(0) = script_file.shellpath
    r = authshell.authorizeandexecute("/bin/sh",args)
    if r then
      do
        authshell.poll
      loop until not authshell.live
    else
      if authshell.errornumber = -60006 then
        // cancelled
      else
        // error
        triggererror authshell.errornumber
      end
    end
    
    // remove the installer script
    script_file.delete
    
    // cleanup the authorization
    authshell = nil