mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -04:00
Improved hostname, added manpage
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
parent
9e4b29b4cf
commit
cba88c7066
@ -1,14 +1,20 @@
|
||||
local args = {...}
|
||||
if args[1] then
|
||||
local file = io.open("/etc/hostname", "w")
|
||||
file:write(args[1])
|
||||
file:close()
|
||||
os.setenv("HOSTNAME", args[1])
|
||||
os.setenv("PS1", "$HOSTNAME:$PWD# ")
|
||||
local file, reason = io.open("/etc/hostname", "w")
|
||||
if not file then
|
||||
io.stderr:write(reason .. "\n")
|
||||
else
|
||||
file:write(args[1])
|
||||
file:close()
|
||||
os.setenv("HOSTNAME", args[1])
|
||||
os.setenv("PS1", "$HOSTNAME:$PWD# ")
|
||||
end
|
||||
else
|
||||
local file = io.open("/etc/hostname")
|
||||
if file then
|
||||
io.write(file:read("*l"))
|
||||
io.write(file:read("*l"), "\n")
|
||||
file:close()
|
||||
else
|
||||
io.stderr:write("Hostname not set\n")
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,12 @@
|
||||
NAME
|
||||
hostname - Display and modify hostname
|
||||
|
||||
SYNOPIS
|
||||
hostname [NEW NAME]
|
||||
|
||||
EXAMPLES
|
||||
hostname
|
||||
Prints currently set hostname
|
||||
|
||||
hostname test
|
||||
Sets hostname of this computer to test
|
Loading…
x
Reference in New Issue
Block a user