-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.pwsl
More file actions
60 lines (60 loc) · 1.52 KB
/
main.pwsl
File metadata and controls
60 lines (60 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// EarthOS shell
//
// Copyright (C) 2021 adazem009
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
include/"interpreter.pwsl"
include/"env.pwsl"
// Get release
//getfile/"/etc/release"/"file"
//getitem/"file",1/"uname"
//getitem/"file",2/"ver"
// Get hostname
getfile/"/etc/hostname"/"file"
set/"ret",%returnc
if/[ret != ""]
geterror/ret,0/"ret"
print/"shell: /etc/hostname: ",ret,\n
set/"hostname","(none)"
else
getitem/"file",1/"hostname"
endif
// Environment setup
set/"pwd","/"/"PATH","/bin:/sbin"
// Get args
getitem/"arg_1",1/"in"
if/[in != ""]
bintolist/in/"command"
_run
exit
endif
_getpaths/PATH/"paths"
set/"user",%whoami,"@",hostname
while/[true]
print/\c"000255000",user,\c255255255,":",\c"000000255",pwd
if/[%whoami == "root"]
print/"# "
else
print/"$ "
endif
read/"","input"
// Process input
_sep/input/"command"
// Find and execute binary
_run
if/[bin == "exit"]
exit
endif
endloop