Feature: Add && (AND-list) operator to the JNode shell
The JNode shell currently does not support command chaining with &&. Commands like cd /tmp && java Test fail because the shell attempts to parse && as part of the first command's arguments or rejects it as invalid syntax.
Use case
Running multiple dependent commands in a single line is a common shell pattern. Without &&:
-
Idempotent command sequences: Many tasks require "if this succeeds, then do that" logic. Examples:
mkdir /tmp/work && echo ready — create dir, then confirm
ping 10.0.2.2 && echo network up — test connectivity, then report
wget http://example.com/file && echo "download complete" — fetch then confirm
device --scan && ifconfig — rescan devices then list interfaces
-
Batch scripts: A future shell scripting feature would naturally build on && support.
Current behavior
[JNODE_AGENT_READY]
> cd /jnode/tmp && java HelloWorld
Command syntax error(s):
Usage: cd ...
The shell either treats && as part of the cd arguments or rejects the entire line as invalid.
Desired behavior
[JNODE_AGENT_READY]
> ping 10.0.2.2 && echo "network ready"
Reply from 10.0.2.2: ...
network ready
[JNODE_AGENT_READY]
The shell should execute the left-hand command, check its exit status, and only execute the right-hand command if the exit status indicates success (zero).
Required semantics (POSIX shell compatible)
command1 && command2: Execute command1. If its exit code is 0, execute command2.
- Chaining:
a && b && c executes left-to-right, stopping at the first failure.
|| (OR-list) is a natural companion but could be deferred to a separate issue.
- Commands on both sides must support all existing shell syntax (arguments, redirections, pipes).
Implementation considerations
-
Parser changes: The shell's command parser (org.jnode.shell.*) needs to recognize && as an operator rather than a regular argument. This likely requires changes to the tokenizer/lexer.
-
Shell execution model: The shell's command runner must evaluate exit codes and conditionally skip subsequent commands. JNode's CommandShell or equivalent execution loop needs to handle AND-list / OR-list AST nodes.
-
Exit code propagation: All commands must consistently return meaningful exit codes. Currently many commands may not set a proper non-zero exit code on failure. This may need to be fixed as a prerequisite or bundled.
-
Backward compatibility: Existing single-command invocations must not be affected. echo hello && world should still echo hello and then fail on world (rather than printing hello && world).
Affected source files (likely)
shell/src/shell/org/jnode/shell/ — parser, tokenizer, command line splitting
shell/src/shell/org/jnode/shell/command/ — command execution and exit code handling
cli/ — CLI shell implementation (may also need updates)
Verification
Test script to run inside JNode:
true && echo one
false && echo two
echo three
Expected output: one then three (no two because false prevents chaining).
Test with javac + java:
javac /tmp/Test.java && java Test
Expected: compiles, then runs.
Agent script test (from host):
python3 jnode_agent_cmd.py "ls /jnode && echo found"
Expected: ls output followed by found.
Feature: Add
&&(AND-list) operator to the JNode shellThe JNode shell currently does not support command chaining with
&&. Commands likecd /tmp && java Testfail because the shell attempts to parse&&as part of the first command's arguments or rejects it as invalid syntax.Use case
Running multiple dependent commands in a single line is a common shell pattern. Without
&&:Idempotent command sequences: Many tasks require "if this succeeds, then do that" logic. Examples:
mkdir /tmp/work && echo ready— create dir, then confirmping 10.0.2.2 && echo network up— test connectivity, then reportwget http://example.com/file && echo "download complete"— fetch then confirmdevice --scan && ifconfig— rescan devices then list interfacesBatch scripts: A future shell scripting feature would naturally build on
&&support.Current behavior
The shell either treats
&&as part of thecdarguments or rejects the entire line as invalid.Desired behavior
The shell should execute the left-hand command, check its exit status, and only execute the right-hand command if the exit status indicates success (zero).
Required semantics (POSIX shell compatible)
command1 && command2: Executecommand1. If its exit code is 0, executecommand2.a && b && cexecutes left-to-right, stopping at the first failure.||(OR-list) is a natural companion but could be deferred to a separate issue.Implementation considerations
Parser changes: The shell's command parser (
org.jnode.shell.*) needs to recognize&&as an operator rather than a regular argument. This likely requires changes to the tokenizer/lexer.Shell execution model: The shell's command runner must evaluate exit codes and conditionally skip subsequent commands. JNode's
CommandShellor equivalent execution loop needs to handle AND-list / OR-list AST nodes.Exit code propagation: All commands must consistently return meaningful exit codes. Currently many commands may not set a proper non-zero exit code on failure. This may need to be fixed as a prerequisite or bundled.
Backward compatibility: Existing single-command invocations must not be affected.
echo hello && worldshould still echohelloand then fail onworld(rather than printinghello && world).Affected source files (likely)
shell/src/shell/org/jnode/shell/— parser, tokenizer, command line splittingshell/src/shell/org/jnode/shell/command/— command execution and exit code handlingcli/— CLI shell implementation (may also need updates)Verification
Test script to run inside JNode:
Expected output:
onethenthree(notwobecausefalseprevents chaining).Test with javac + java:
Expected: compiles, then runs.
Agent script test (from host):
python3 jnode_agent_cmd.py "ls /jnode && echo found"Expected:
lsoutput followed byfound.