can1357/oh-my-pi · error · SortError
when reading file names from standard input, no file name of
Error message
when reading file names from standard input, no file name of '-' allowed
What it means
SortError::MinusInStdIn is thrown when the --files0-from list (read from standard input via `--files0-from=-`) contains the entry `-`. Since the list itself is already being read from stdin, `-` has no meaning as a file name and GNU-compatible sort rejects it explicitly.
Source
Thrown at crates/pi-builtins/src/sort.rs:2624
OpenTmpFileFailed { error: std::io::Error },
#[error("could not run compress program '{}': {}", .prog, strip_errno(.error))]
CompressProgExecutionFailed { prog: String, error: std::io::Error },
#[error("{} terminated abnormally", .prog.quote())]
CompressProgTerminatedAbnormally { prog: String },
#[error("cannot create temporary file in {}:", .path.quote())]
TmpFileCreationFailed { path: PathBuf },
#[error("extra operand {}\nfile operands cannot be combined with --files0-from\nTry 'sort --help' for more information.", .file.quote())]
FileOperandsCombined { file: PathBuf },
#[error("multiple output files specified")]
MultipleOutputFiles,
#[error("when reading file names from standard input, no file name of '-' allowed")]
MinusInStdIn,
#[error("no input from {}", .file.quote())]
EmptyInputFile { file: PathBuf },
#[error("{}:{}: invalid zero-length file name", .file.maybe_quote(), .line_num)]
ZeroLengthFileName { file: PathBuf, line_num: usize },
}
impl SortError {
fn message(message: impl Into<String>) -> Self {
Self::Message(message.into())
}
fn code(&self) -> i32 {
if matches!(self, Self::Disorder { .. }) { 1 } else { 2 }
}
}View on GitHub (pinned to 9690622007)
Solutions
- Remove `-` entries from the NUL-separated list before feeding it to --files0-from=-.
- Replace `-` with the actual path if a real file was intended.
- Filter the list: e.g. `printf '%s\0' ... | grep -zv '^-$' | sort --files0-from=-`.
Example fix
// before printf 'a.txt\0-\0b.txt\0' | sort --files0-from=- // after printf 'a.txt\0b.txt\0' | sort --files0-from=-
Defensive patterns
Strategy: validation
Validate before calling
// sanitize a NUL-separated stdin list before --files0-from=-
const entries = list.split("\0").filter(e => e !== "" && e !== "-");
const cleaned = entries.join("\0") + "\0";
// pipe `cleaned` to sort --files0-from=- Type guard
const isValidEntry = (e: string): boolean => e.length > 0 && e !== "-";
Try / catch
try {
await sort(["--files0-from=-"], { stdin: listStream });
} catch (err) {
if (String(err).includes("no file name of '-' allowed")) {
await sort(["--files0-from=-"], { stdin: stripMinusEntries(listStream) });
} else throw err;
} Prevention
- Never include '-' as an entry when the list itself comes from stdin.
- Filter generated lists for '-' placeholders before feeding --files0-from.
- Build lists programmatically from real paths rather than manual strings.
- Unit-test list generators against entries containing '-'.
When it happens
Trigger: Piping a NUL-separated file list to `sort --files0-from=-` where one of the entries is the literal string `-`, e.g. `printf 'a.txt\0-\0' | sort --files0-from=-`.
Common situations: Generated file lists that include `-` as a placeholder for stdin; tools like find/du output post-processing where '-' sneaks in from other command conventions.
Related errors
- extra operand {} file operands cannot be combined with --fil
- multiple output files specified
- too many templates
- could not run compress program '{}': {}
- {} terminated abnormally
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/54ae5717b69746c7.
Report an issue: GitHub.