7
程序可以告诉它正在sudo下运行吗?
我有一个程序,如果在“ sudo”下运行,其行为应有所不同。有没有办法找出它是否在sudo下运行? 更新:有人问我为什么要这样做。在这种情况下,在使用MacPorts的Mac上,输出将告诉您剪切并粘贴特定命令。如果MacPorts命令以“ sudo”运行,则在示例命令中应包含sudo: $ sudo port selfupdate ---> Updating MacPorts base sources using rsync MacPorts base version 2.2.1 installed, MacPorts base version 2.2.1 downloaded. ---> Updating the ports tree ---> MacPorts base is already the latest version The ports tree has been updated. To upgrade your installed ports, you …