@@ -70,6 +70,9 @@ pub enum LnError {
7070 #[ error( "{}" , translate!( "ln-error-missing-destination" , "operand" => _0. quote( ) ) ) ]
7171 MissingDestination ( PathBuf ) ,
7272
73+ #[ error( "{}" , translate!( "ln-error-missing-operand" ) ) ]
74+ MissingOperand ,
75+
7376 #[ error( "{}" , translate!( "ln-error-extra-operand" , "operand" => _0. quote( ) , "program" => _1. clone( ) ) ) ]
7477 ExtraOperand ( OsString , String ) ,
7578
@@ -270,6 +273,10 @@ pub fn uu_app() -> Command {
270273///
271274/// This is made public to allow other apps to use `ln` as a library.
272275pub fn exec ( files : & [ PathBuf ] , settings : & Settings ) -> LnResult < ( ) > {
276+ if files. is_empty ( ) {
277+ return Err ( LnError :: MissingOperand ) ;
278+ }
279+
273280 // Handle cases where we create links in a directory first.
274281 if let Some ( ref target_path) = settings. target_dir {
275282 // 4th form: a directory is specified by -t.
@@ -298,7 +305,6 @@ pub fn exec(files: &[PathBuf], settings: &Settings) -> LnResult<()> {
298305 uucore:: execution_phrase ( ) . to_string ( ) ,
299306 ) ) ;
300307 }
301- assert ! ( !files. is_empty( ) ) ;
302308
303309 link ( & files[ 0 ] , & files[ 1 ] , settings)
304310}
0 commit comments