can1357/oh-my-pi · error · SortError
multiple output files specified
Error message
multiple output files specified
What it means
SortError::MultipleOutputFiles is thrown when more than one output file is specified. sort accepts at most a single -o/--output target; extra operands after the first -o are rejected because output cannot be split across files.
Source
Thrown at crates/pi-builtins/src/sort.rs:2621
ReadFailed { path: PathBuf, error: std::io::Error },
#[error("failed to open temporary file: {}", strip_errno(.error))]
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 {View on GitHub (pinned to 9690622007)
Solutions
- Pass exactly one -o/--output file.
- Use `tee` or explicit separate invocations if multiple outputs are genuinely needed.
- Fix wrapper scripts to take the last/single configured output path rather than joining an array.
Example fix
// before sort -o a.txt -o b.txt input.txt // after sort -o a.txt input.txt
Defensive patterns
Strategy: validation
Validate before calling
// ensure at most one -o/--output before invoking sort
const outputs = args.filter(a => a === "-o" || a === "--output");
if (outputs.length > 1) throw new Error("at most one -o/--output is allowed"); Try / catch
try {
await sort(args);
} catch (err) {
if (String(err).includes("multiple output files")) {
// fall back to the last configured output only
await sort(dedupeOutputFlags(args));
} else throw err;
} Prevention
- Never append -o inside loops that build sort arguments.
- Deduplicate output flags in wrapper scripts, keeping the last value.
- Use tee for genuine multi-destination output instead of multiple -o flags.
- Assert single-output configuration at script startup.
When it happens
Trigger: Invoking the sort builtin with multiple -o options (e.g. `sort -o a.txt -o b.txt input`) or otherwise arranging for more than one output file operand.
Common situations: Shell scripts that append `-o $OUT` in a loop, producing several output flags; copy-paste mistakes; config-driven wrappers that join an array of output paths into repeated -o flags.
Related errors
- extra operand {} file operands cannot be combined with --fil
- when reading file names from standard input, no file name of
- Invalid quoting style: {style}
- validate requires a finding URI or <scan-id> <finding-id>
- show requires a scan id or security:// URI
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/ba795129cf1e93e9.
Report an issue: GitHub.