{"record":{"id":"037e6fd976690d99","repo":"can1357/oh-my-pi","slug":"extra-operand-try-help-for-more-informat","errorCode":null,"errorMessage":"extra operand {}\nTry '{} --help' for more information.","messagePattern":"extra operand (.+?)\nTry '(.+?) --help' for more information\\.","errorType":"error_code","errorClass":"LnError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/ln.rs","lineNumber":65,"sourceCode":"\tInteractive,\n\tForce,\n}\n\n#[derive(Error, Debug)]\nenum LnError {\n\t#[error(\"target {} is not a directory\", _0.quote())]\n\tTargetIsNotADirectory(PathBuf),\n\n\t#[error(\"\")]\n\tSomeLinksFailed,\n\n\t#[error(\"{} and {} are the same file\", _0.quote(), _1.quote())]\n\tSameFile(PathBuf, PathBuf),\n\n\t#[error(\"missing destination file operand after {}\", _0.quote())]\n\tMissingDestination(PathBuf),\n\n\t#[error(\"extra operand {}\\nTry '{} --help' for more information.\", _0.quote(), _1)]\n\tExtraOperand(OsString, String),\n\n\t#[error(\"{}: hard link not allowed for directory\", _0.to_string_lossy())]\n\tFailedToCreateHardLinkDir(PathBuf),\n\n\t#[error(\"{0}\")]\n\tMessage(String),\n\n\t#[error(\"{0}\")]\n\tIo(#[from] std::io::Error),\n}\n\n\nmod options {\n\tpub const FORCE: &str = \"force\";\n\t//pub const DIRECTORY: &str = \"directory\";\n\tpub const INTERACTIVE: &str = \"interactive\";\n\tpub const NO_DEREFERENCE: &str = \"no-dereference\";","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/ln.rs#L47-L83","documentation":"The ln builtin's ExtraOperand variant fires when more operands are supplied than the link mode accepts. In plain (non-directory-destination) mode ln takes exactly source and destination; a third or later operand triggers this coreutils-style message with a --help hint. The OsString is the offending extra operand and the String is the program name used in the hint.","triggerScenarios":"Calling ln with three or more path arguments without a directory destination, e.g. `ln a b c`.","commonSituations":"Scripts that join many files into one ln call expecting GNU's 'link all into directory' mode while the last argument is not a directory; typo'd extra path.","solutions":["Ensure the final operand is an existing directory when linking multiple sources","Split into multiple ln calls, one per source/destination pair","Remove the extra operand from the argument list"],"exampleFix":"// before\nln(&host, &[\"a.txt\", \"b.txt\", \"links/\"])?; // if \"links/\" doesn't exist\n// after\nstd::fs::create_dir(\"links\")?; // or use explicit pairs\nln(&host, &[\"a.txt\", \"links/a.txt\"])?;\nln(&host, &[\"b.txt\", \"links/b.txt\"])?;","handlingStrategy":"validation","validationCode":"fn validate_arity(args: &[&OsStr]) -> Result<(), &'static str> {\n    match args.len() {\n        2 => Ok( ),\n        n if n > 2 => {\n            let last = std::path::Path::new(args.last().unwrap());\n            if last.is_dir() { Ok( ) } else { Err(\"multiple sources require a directory destination\") }\n        }\n        _ => Err(\"need source and destination\"),\n    }\n}","typeGuard":null,"tryCatchPattern":"match ln(&host, args) {\n    Err(e) if e.to_string().starts_with(\"extra operand\") => eprintln!(\"pass at most SOURCE DEST, or end with an existing directory\"),\n    other => other?,\n}","preventionTips":["Verify the last operand is an existing directory before batching multiple sources","Keep argument lists to exactly two paths in simple link calls"],"tags":["filesystem","hardlink","argument-error"],"backgroundTag":"extra-operand","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}