System/Shell/Commands: Use original argv as pathname in error messages

This commit is contained in:
Alec Murphy
2025-09-20 10:24:25 -04:00
parent 3d2cc73e43
commit 682ca552d3
3 changed files with 4 additions and 5 deletions

View File

@@ -12,11 +12,10 @@ I64 @shell_cmd_aplay(@shell* sh, I64 argc, U8** argv)
U8* filename = NULL; U8* filename = NULL;
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
filename = @shell_expand_relative_path(sh, argv[i]); filename = @shell_expand_relative_path(sh, argv[i]);
System.Log(Fs, "filename: %s", filename);
if (FileSystem.PathExists(filename)) { if (FileSystem.PathExists(filename)) {
snd = Audio.SoundFromFile(filename); snd = Audio.SoundFromFile(filename);
if (!snd) { if (!snd) {
StrPrint(&buf, "%s: Error playing audio file\n", filename); StrPrint(&buf, "%s: Error playing audio file\n", argv[i]);
Stdio.WriteLine(sh, &buf); Stdio.WriteLine(sh, &buf);
Free(filename); Free(filename);
return 1; return 1;
@@ -25,7 +24,7 @@ I64 @shell_cmd_aplay(@shell* sh, I64 argc, U8** argv)
Audio.FreeSound(snd); Audio.FreeSound(snd);
Free(filename); Free(filename);
} else { } else {
StrPrint(&buf, "%s: No such file or directory\n", filename); StrPrint(&buf, "%s: No such file or directory\n", argv[i]);
Stdio.WriteLine(sh, &buf); Stdio.WriteLine(sh, &buf);
Free(filename); Free(filename);
return 1; return 1;

View File

@@ -32,7 +32,7 @@ I64 @shell_cmd_cat(@shell* sh, I64 argc, U8** argv)
filename = @shell_expand_relative_path(sh, argv[i]); filename = @shell_expand_relative_path(sh, argv[i]);
if (!FileSystem.PathExists(filename)) { if (!FileSystem.PathExists(filename)) {
res = 2; res = 2;
StrPrint(&msg, "cat: cannot access '%s': No such file or directory\n", filename); StrPrint(&msg, "cat: cannot access '%s': No such file or directory\n", argv[i]);
Stdio.WriteLine(sh, &msg); Stdio.WriteLine(sh, &msg);
} else { } else {
buf = FileSystem.ReadFile(filename, &size); buf = FileSystem.ReadFile(filename, &size);

View File

@@ -6,7 +6,7 @@ I64 @shell_cmd_ls_output(@shell* sh, U8* arg_path, I64 flags)
U8 buf[512]; U8 buf[512];
U8* path = @shell_expand_relative_path(sh, arg_path); U8* path = @shell_expand_relative_path(sh, arg_path);
if (!FileSystem.PathExists(path)) { if (!FileSystem.PathExists(path)) {
StrPrint(&buf, "ls: cannot access '%s': No such file or directory\n", path); StrPrint(&buf, "ls: cannot access '%s': No such file or directory\n", arg_path);
Stdio.WriteLine(sh, &buf); Stdio.WriteLine(sh, &buf);
Free(path); Free(path);
return 2; return 2;