Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/uu/ln/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ln-help-verbose = print name of each linked file
ln-error-target-is-not-directory = target {$target} is not a directory
ln-error-same-file = {$file1} and {$file2} are the same file
ln-error-missing-destination = missing destination file operand after {$operand}
ln-error-missing-operand = missing operand
ln-error-extra-operand = extra operand {$operand}
Try '{$program} --help' for more information.
ln-error-could-not-update = Could not update {$target}: {$error}
Expand Down
1 change: 1 addition & 0 deletions src/uu/ln/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ln-help-verbose = afficher le nom de chaque fichier lié
ln-error-target-is-not-directory = la cible {$target} n'est pas un répertoire
ln-error-same-file = {$file1} et {$file2} sont le même fichier
ln-error-missing-destination = opérande de fichier de destination manquant après {$operand}
ln-error-missing-operand = opérande manquant
ln-error-extra-operand = opérande supplémentaire {$operand}
Essayez « {$program} --help » pour plus d'informations.
ln-error-could-not-update = Impossible de mettre à jour {$target} : {$error}
Expand Down
8 changes: 7 additions & 1 deletion src/uu/ln/src/ln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ pub enum LnError {
#[error("{}", translate!("ln-error-missing-destination", "operand" => _0.quote()))]
MissingDestination(PathBuf),

#[error("{}", translate!("ln-error-missing-operand"))]
MissingOperand,

#[error("{}", translate!("ln-error-extra-operand", "operand" => _0.quote(), "program" => _1.clone()))]
ExtraOperand(OsString, String),

Expand Down Expand Up @@ -270,6 +273,10 @@ pub fn uu_app() -> Command {
///
/// This is made public to allow other apps to use `ln` as a library.
pub fn exec(files: &[PathBuf], settings: &Settings) -> LnResult<()> {
if files.is_empty() {
return Err(LnError::MissingOperand);
}

// Handle cases where we create links in a directory first.
if let Some(ref target_path) = settings.target_dir {
// 4th form: a directory is specified by -t.
Expand Down Expand Up @@ -298,7 +305,6 @@ pub fn exec(files: &[PathBuf], settings: &Settings) -> LnResult<()> {
uucore::execution_phrase().to_string(),
));
}
assert!(!files.is_empty());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match files.len()

I considered a match but wanted to move the check to the start of the function.


link(&files[0], &files[1], settings)
}
Expand Down
Loading