Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fdad708
Shell: expand tabs to spaces
pulchart Nov 22, 2026
8c4f738
Be more precise when handling + continuation
Nov 7, 2020
377808d
Run: don't announce the background CLI number when output is redirected
jonx Jul 18, 2026
4c59327
Shell: preserve escaped quotes while reading lines
warpdesign Jul 20, 2026
2d210cf
Shell: report errors from parsing and redirection
codewiz Aug 1, 2026
c1306ae
Shell: fix buffer reallocation free size
cyberman Sep 5, 2026
2083516
Shell: bound .key and .def argument names
cyberman Sep 5, 2026
2402c5f
Shell: fix ReadArgs ownership across interpreter state
cyberman Sep 5, 2026
af547fb
Shell: finalize embedded interpreter state
cyberman Sep 6, 2026
0e4989b
Shell: delete backtick temporary output file
cyberman Sep 6, 2026
2024a55
Shell: inherit CLI number in backtick state
cyberman Sep 7, 2026
8ba1495
Shell: match dot argument names exactly
cyberman Sep 7, 2026
b56716d
Shell: require full .pushis and .popis names
cyberman Sep 7, 2026
db1bf1a
Run: preserve redirected output handles and append position
tomaszstaniak Sep 9, 2026
f135c97
Shell: accept signed .key /N values
cyberman Sep 13, 2026
a3b9c26
Shell: accept mixed-case .pushis and .popis
cyberman Sep 14, 2026
269ff0c
Shell: unload cli_Module after a command, like the Kickstart CLI (#1778)
tonimanot71-bot Oct 22, 2026
6a03bc3
shell: keep the redirections of Run's child command
pulchart Nov 22, 2026
44e256b
Run: preserve quoted child command names (#1714)
warpdesign Oct 19, 2026
cf30907
Run: run every '+' continuation line once (#2374)
pulchart Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions developer/debug/test/dos/README.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Run redirection regression
==========================

run_redirection takes an explicit path to a standalone Run executable.
Build it through test-dos-common, or directly with the AROS target compiler.
Build Run.c in standalone form with -nostartfiles -static and an ADATE string.
Do not replace the installed/resident command for this test.

run_redirection RAM:Run-fixed

The probe creates a unique directory in RAM:, verifies a successful launch
and exact output for both > and >>, including a pre-existing PREFIX line.
It waits up to 250 ticks for each asynchronous Echo. On success it removes
its files and empty directory; after failure it retains them, without
reusing a possibly still-active background command's output pathname.

The unmodified Run is expected to fail these output checks on the tested
RAM-handler. Comparing baseline/fixed executables by explicit path avoids
accidentally running a resident command instead of the patched binary.

Fault injection (host only)
---------------------------
From this directory:

cc -std=c99 -Wall -Wextra -Werror -fsanitize=address,undefined \
run_handle_host.c -o /tmp/run_handle_host
/tmp/run_handle_host

This compiles the actual production run_handle.h with DOS boundary doubles.
It checks source seek failures and unrepresentable positions, unsupported
seeks, exclusive-to-shared retry, failed OpenFromLock cleanup, failed copy
seek cleanup, and interactive handles. It is not a native handler test or
allocation-failure test of the entire Run command.

Compatibility limits
--------------------
The duplication helper uses the existing LONG-based Seek API. Negative
positions other than -1/ERROR_ACTION_NOT_KNOWN are rejected rather than
silently reopening a seekable output at offset zero. Positions above
LONG_MAX are not supported by this path. Only interactive handles and
explicitly unsupported Seek operations are duplicated without a position.

Exclusive output is changed to SHARED_LOCK only after DupLockFromFH reports
ERROR_OBJECT_IN_USE. That mode change is not rolled back if a later operation
fails. Concurrent append atomicity, other filesystems and allocation-failure
injection across the entire Shell launch are outside this regression.
5 changes: 3 additions & 2 deletions developer/debug/test/dos/mmakefile.src
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ FILES := \
readitem \
readitemloop \
runcommand \
run_redirection \
rwverify \
scantest \
scanvarstest \
Expand All @@ -54,8 +55,8 @@ EXEDIR := $(AROS_TESTS)/dos

USER_CFLAGS += -DADATE="\"$(shell date '+%d.%m.%Y')\""

#MM- test : test-dos test-dos-pure
#MM- test-quick : test-dos-quick test-dos-pure-quick
#MM- test : test-dos test-dos-pure test-dos-runcommandredir
#MM- test-quick : test-dos-quick test-dos-pure-quick test-dos-runcommandredir-quick

#MM test-dos : includes linklibs

Expand Down
84 changes: 84 additions & 0 deletions developer/debug/test/dos/run_handle_host.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* Copyright (C) 2026, The AROS Development Team. All rights reserved. */
/* Host-only fault injection around the actual production duplication helper.
cc -std=c99 -Wall -Wextra -Werror run_handle_host.c -o run_handle_host */
#include <stdint.h>
#include <assert.h>
#include <stdio.h>
typedef intptr_t BPTR;
typedef int32_t LONG;
struct DosLibrary { int unused; };
#define BNULL 0
#define OFFSET_CURRENT 0
#define OFFSET_BEGINNING -1
#define CHANGE_FH 1
#define SHARED_LOCK -2
#define ERROR_INVALID_LOCK 211
#define ERROR_OBJECT_IN_USE 202
#define ERROR_ACTION_NOT_KNOWN 209
#define ERROR_SEEK_ERROR 219
static LONG error, position, seek_error;
static int interactive, exclusive, share_ok, open_ok, restore_ok;
static unsigned seeks, duplicates, shares, unlocks, closes;
static LONG get_error(struct DosLibrary *base) { (void)base;return error; }
static void set_error(LONG e,struct DosLibrary *base) { (void)base;error=e; }
static int is_interactive(BPTR f,struct DosLibrary *base)
{ (void)base;assert(f==1);return interactive; }
static LONG seek_file(BPTR f,LONG offset,LONG mode,struct DosLibrary *base)
{
(void)base;++seeks;
if(f==1) { assert(offset==0 && mode==OFFSET_CURRENT);error=seek_error;return position; }
assert(f==3 && offset==position && mode==OFFSET_BEGINNING);
error=ERROR_SEEK_ERROR;return restore_ok?0:-1;
}
static BPTR duplicate(BPTR f,struct DosLibrary *base)
{
(void)base;assert(f==1);++duplicates;
if(exclusive && !shares) { error=ERROR_OBJECT_IN_USE;return 0; }
return 2;
}
static int change_mode(LONG type,BPTR f,LONG mode,struct DosLibrary *base)
{ (void)base;assert(type==CHANGE_FH && f==1 && mode==SHARED_LOCK);++shares;error=223;return share_ok; }
static BPTR open_lock(BPTR l,struct DosLibrary *base)
{ (void)base;assert(l==2);error=103;return open_ok?3:0; }
static void unlock(BPTR l,struct DosLibrary *base)
{ (void)base;assert(l==2);++unlocks;error=0; }
static void close_file(BPTR f,struct DosLibrary *base)
{ (void)base;assert(f==3);++closes;error=0; }
#define IoErr() get_error(DOSBase)
#define SetIoErr(e) set_error((e),DOSBase)
#define IsInteractive(f) is_interactive((f),DOSBase)
#define Seek(f,p,m) seek_file((f),(p),(m),DOSBase)
#define DupLockFromFH(f) duplicate((f),DOSBase)
#define ChangeMode(t,f,m) change_mode((t),(f),(m),DOSBase)
#define OpenFromLock(l) open_lock((l),DOSBase)
#define UnLock(l) unlock((l),DOSBase)
#define Close(f) close_file((f),DOSBase)
#include "../../../../workbench/c/shellcommands/run_handle.h"
static void reset(void)
{
error=seek_error=0;position=7;interactive=exclusive=0;
share_ok=open_ok=restore_ok=1;
seeks=duplicates=shares=unlocks=closes=0;
}
int main(void)
{
reset();position=-1;seek_error=ERROR_SEEK_ERROR;
assert(DuplicateRunHandle(1,NULL)==0 && error==ERROR_SEEK_ERROR && !duplicates);
reset();position=INT32_MIN;
assert(DuplicateRunHandle(1,NULL)==0 && error==ERROR_SEEK_ERROR && !duplicates);
reset();position=-1;seek_error=ERROR_ACTION_NOT_KNOWN;
assert(DuplicateRunHandle(1,NULL)==3 && seeks==1);
reset();exclusive=1;
assert(DuplicateRunHandle(1,NULL)==3 && shares==1 && duplicates==2 && seeks==2);
reset();exclusive=1;share_ok=0;
assert(DuplicateRunHandle(1,NULL)==0 && error==223 && duplicates==1);
reset();open_ok=0;
assert(DuplicateRunHandle(1,NULL)==0 && error==103 && unlocks==1 && !closes);
reset();restore_ok=0;
assert(DuplicateRunHandle(1,NULL)==0 && error==ERROR_SEEK_ERROR && closes==1 && !unlocks);
reset();interactive=1;
assert(DuplicateRunHandle(1,NULL)==3 && !seeks);
reset();assert(DuplicateRunHandle(0,NULL)==0 && error==ERROR_INVALID_LOCK && !duplicates);
puts("RUN HANDLE PASS: seek failures, range rejection, nonseekable, sharing, ownership");
return 0;
}
85 changes: 85 additions & 0 deletions developer/debug/test/dos/run_redirection.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* Copyright (C) 2026, The AROS Development Team. All rights reserved. */
/* Run an explicit standalone Run executable; never replace resident Run. */
#include <proto/dos.h>
#include <proto/exec.h>
#include <dos/dostags.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
struct Process *me = (struct Process *)FindTask(NULL);
char directory[120], path[2][160], command[500], data[128];
const char *expected[2] = {"RUN_REDIRECT_OK\n", "PREFIX\nRUN_REDIRECT_OK\n"};
BPTR lock, file;
unsigned attempt, round, ticks;
LONG result, count;
int all_ok = 1, matched;

if (argc != 2 || strlen(argv[1]) > 240 || strpbrk(argv[1], "\"*\r\n"))
{
puts("Usage: run_redirection <explicit standalone Run executable>");
return RETURN_FAIL;
}
/* CreateDir is the ownership boundary. Never truncate a pre-existing file. */
for (attempt = 0; attempt < 100; ++attempt)
{
snprintf(directory, sizeof directory, "RAM:run-redirection-%lu-%u",
(unsigned long)me->pr_TaskNum, attempt);
lock = CreateDir((CONST_STRPTR)directory);
if (lock) { UnLock(lock); break; }
if (IoErr() != ERROR_OBJECT_EXISTS) return RETURN_FAIL;
}
if (attempt == 100) return RETURN_FAIL;
snprintf(path[0], sizeof path[0], "%s/overwrite", directory);
snprintf(path[1], sizeof path[1], "%s/append", directory);

for (round = 0; round < 2; ++round)
{
matched = 0;
if (round)
{
file = Open((CONST_STRPTR)path[round], MODE_NEWFILE);
if (!file) { all_ok = 0; break; }
count = Write(file, "PREFIX\n", 7);
if (!Close(file) || count != 7) { all_ok = 0; break; }
}
snprintf(command, sizeof command, "\"%s\" %s%s Echo RUN_REDIRECT_OK",
argv[1], round ? ">>" : ">", path[round]);
result = SystemTags((CONST_STRPTR)command, SYS_Asynch, FALSE, TAG_DONE);
for (ticks = 0; result == RETURN_OK && ticks < 250; ++ticks)
{
file = Open((CONST_STRPTR)path[round], MODE_OLDFILE);
if (file)
{
count = Read(file, data, sizeof data - 1);
Close(file);
if (count >= 0)
{
data[count] = 0;
if ((size_t)count == strlen(expected[round]) &&
!memcmp(data, expected[round], (size_t)count))
{ matched = 1; break; }
}
}
Delay(1);
}
printf("RUN %s %s: launch=%ld exact_output=%d\n",
round ? "APPEND" : "REDIRECT", matched ? "PASS" : "FAIL",
(long)result, matched);
if (!matched) all_ok = 0;
}
if (all_ok)
{
/* A background Echo may still be closing its output after the read. */
for (round = 0; round < 2; ++round)
{
for (ticks = 0; ticks < 250 && !DeleteFile((CONST_STRPTR)path[round]); ++ticks) Delay(1);
if (ticks == 250) all_ok = 0;
}
if (all_ok && !DeleteFile((CONST_STRPTR)directory)) all_ok = 0;
}
if (!all_ok) printf("Test files retained: %s\n", directory);
puts(all_ok ? "RUN REDIRECTION PASS: launch status, exact bytes, cleanup" : "RUN REDIRECTION FAIL");
return all_ok ? RETURN_OK : RETURN_FAIL;
}
38 changes: 38 additions & 0 deletions developer/debug/test/dos/runcommandredir/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Run child-command redirection regression
=======================================

Build with test-dos-runcommandredir or test-dos-runcommandredir-quick.
Both are selected beneath the DOS component's normal and quick test groups.
Run runcommandredir beside runcommandchild, or pass the child's path as its
first argument. Child paths are quoted in every launch case.

The parent creates an owned directory in RAM:. The child reads its Input(),
writes those exact bytes to Output(), and writes a separate completion file.
This checks that the child really runs, independently of SystemTagList's return
code. Before the fix, RunBack's repeated NIL form returns success without
executing the child; the test fails on the missing completion file.

Coverage includes RunBack's exact NIL form, distinct outer and child input/output
files, case-insensitive Run with QUIET, a plain Run with child redirections,
quoted child paths, '+' continuation lines, failed outer input, ordinary
duplicate redirections, and subsequent shell usability. Successful runs remove
their temporary files; failed asynchronous launches retain evidence rather than
reuse their paths.

Expected result: RUN COMMAND REDIR TEST: 0 failures.

Quoted command regression
-------------------------
Run runquotedcommand beside runcommandchild. It copies the child into its own
RAM: directory under names containing spaces, stars and double quotes, then
checks the child's completion file and redirected output. Its argument and
redirection paths also contain spaces. Coverage includes QUIET, mixed case,
the COMMAND keyword (with and without '='), and outer Run redirections.
An additional check keeps commands entered after Run's '?' help prompt working.
The unchanged Run loses the child filename's quoting and fails the first case.
Expected result: RUN QUOTED TEST: 0 failures.

For a focused external probe, runcommandredir still accepts a child's path
followed by PLAIN to exercise only the ordinary Run control.

Copyright (C) 2026, The AROS Development Team. All rights reserved.
12 changes: 12 additions & 0 deletions developer/debug/test/dos/runcommandredir/mmakefile.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (C) 2026, The AROS Development Team. All rights reserved.

include $(SRCDIR)/config/aros.cfg
USER_LDFLAGS := -static

#MM test-dos-runcommandredir : includes linklibs

%build_progs mmake=test-dos-runcommandredir \
files="runcommandredir runcommandchild runquotedcommand" \
targetdir=$(AROS_TESTS)/dos/runcommandredir

%common
30 changes: 30 additions & 0 deletions developer/debug/test/dos/runcommandredir/runcommandchild.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright (C) 2026, The AROS Development Team. All rights reserved. */
#include <proto/dos.h>

int main(int argc, char **argv)
{
char data[64];
BPTR result;
LONG count;

if (argc != 2)
return RETURN_FAIL;
count = Read(Input(), data, sizeof data);
if (count < 0 || Write(Output(), data, count) != count)
return RETURN_FAIL;
result = Open((CONST_STRPTR)argv[1], MODE_NEWFILE);
if (!result)
return RETURN_FAIL;
if (!count)
{
data[0] = 'E'; data[1] = 'M'; data[2] = 'P';
data[3] = 'T'; data[4] = 'Y'; data[5] = '\n';
count = 6;
}
if (Write(result, data, count) != count)
{
Close(result);
return RETURN_FAIL;
}
return Close(result) ? RETURN_OK : RETURN_FAIL;
}
Loading