Browse Source

Minor cleanup for readability

Alois Mahdal 5 days ago
parent
commit
8c8c3d273c
1 changed files with 11 additions and 1 deletions
  1. 11
    1
      app/main.go

+ 11
- 1
app/main.go View File

@@ -145,12 +145,17 @@ func parseCommand(command_line string) (Command, error) {
145 145
 func handleCommand(ctx Context, command Command) ExitStatus {
146 146
 	// fmt.Printf("handleCommand():command=%#v\n", command)
147 147
 	switch command.command_type {
148
+
148 149
 	case CommandTypeNone:
149 150
 		return 0
151
+
150 152
 	case CommandTypeBuiltinExit:
151 153
 		os.Exit(0)
154
+
152 155
 	case CommandTypeBuiltinEcho:
153 156
 		fmt.Fprintln(ctx.stdout, strings.Join(command.tokens[1:], " "))
157
+		return 0
158
+
154 159
 	case CommandTypeBuiltinPwd:
155 160
 		if len(command.tokens) != 1 {
156 161
 			fmt.Fprintln(ctx.stderr, "usage: pwd")
@@ -161,6 +166,8 @@ func handleCommand(ctx Context, command Command) ExitStatus {
161 166
 			panic("error getting current working directory")
162 167
 		}
163 168
 		fmt.Fprintln(ctx.stdout, cwd_path)
169
+		return 0
170
+
164 171
 	case CommandTypeBuiltinType:
165 172
 		if len(command.tokens) != 2 {
166 173
 			fmt.Fprintln(ctx.stderr, "usage: type COMMAND")
@@ -179,6 +186,8 @@ func handleCommand(ctx Context, command Command) ExitStatus {
179 186
 		default:
180 187
 			fmt.Fprintf(ctx.stdout, "%s is a shell builtin\n", parsed.tokens[0])
181 188
 		}
189
+		return 0
190
+
182 191
 	case CommandTypeExternal:
183 192
 		cmd := exec.Command(command.exec_path, command.tokens[1:]...)
184 193
 		cmd.Args = command.tokens
@@ -195,7 +204,8 @@ func handleCommand(ctx Context, command Command) ExitStatus {
195 204
 				return ExitStatus(65535)
196 205
 			}
197 206
 		}
198
-		return ExitStatus(0)
207
+		return 0
208
+
199 209
 	default:
200 210
 		panic("unknown command type")
201 211
 	}