add non-interactive mode: -c, script files and commands from stdin
- gosh -c 'command' runs the command and exits, so gosh works as login shell for ssh host command, scp and rsync - gosh script runs a script file, lines starting with # are skipped - without a terminal, commands are read from stdin (byte by byte, so started commands can read the rest of stdin) - the exit status is the one of the last command (127 not found, 126 not executable, 128+n killed by signal n) - -i forces interactive mode, -l/--login is accepted Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f51680f83c
commit
b602e17622
3 files changed
+252
-7
No files matched your search
@@ -29,9 +29,32 @@ Features:
|
||||
disabled with $NO_COLOR, TERM=dumb or when output is not a terminal
|
||||
- Environment variable expansion ($VAR, ${VAR}, ${VAR:-default});
|
||||
using an unset variable is an error, use ${VAR:-} for an empty default
|
||||
- Non-interactive use: gosh -c 'command', gosh script, command | gosh;
|
||||
the exit status is the one of the last command
|
||||
|
||||
```
|
||||
|
||||
### Aufruf
|
||||
|
||||
```
|
||||
gosh [-l] [-i] [script]
|
||||
gosh [-l] -c command
|
||||
gosh -version
|
||||
```
|
||||
|
||||
| Aufruf | Verhalten |
|
||||
|------------------------|------------------------------------------------------------------|
|
||||
| `gosh` | interaktive Shell (wenn stdin ein Terminal ist) |
|
||||
| `gosh -c 'befehl'` | führt den Befehl aus und beendet sich |
|
||||
| `gosh skript.gosh` | führt das Skript Zeile für Zeile aus |
|
||||
| `befehle \| gosh` | liest die Befehle von stdin |
|
||||
| `-i` | erzwingt den interaktiven Modus, auch ohne Terminal |
|
||||
| `-l`, `--login` | Login-Shell (wird akzeptiert, eine Startdatei gibt es noch nicht) |
|
||||
|
||||
Ohne Terminal bricht gosh bei einem fehlgeschlagenen Befehl nicht ab und beendet sich mit dem Exit-Status des letzten Befehls: `127`, wenn ein Befehl nicht gefunden wurde, `126`, wenn er nicht ausführbar ist, `128+n`, wenn er durch Signal `n` beendet wurde. Leere Zeilen und Zeilen, die mit `#` beginnen, werden übersprungen, Skripte können also mit `#!/usr/bin/gosh` beginnen.
|
||||
|
||||
Damit funktionieren auch `ssh host befehl`, `scp` und `rsync`, wenn gosh als Login-Shell gesetzt ist. Da gosh `;`, `&&` und Pipes noch nicht kennt, darf der Befehl dabei aber nur aus einem einfachen Kommando bestehen.
|
||||
|
||||
### Farben
|
||||
|
||||
Der Prompt wird über die Umgebungsvariable `GOSH_COLORS` eingefärbt. Sie besteht aus durch `:` getrennten Einträgen `schlüssel=code`:
|
||||
|
||||
Reference in new issue
Block a user