@@ -12,10 +12,12 @@ use uucore::format_usage;
1212
1313use uucore:: display:: println_verbatim;
1414use uucore:: error:: { FromIo , UResult } ;
15+ use uucore:: show_error;
1516
1617use uucore:: translate;
1718const OPT_LOGICAL : & str = "logical" ;
1819const OPT_PHYSICAL : & str = "physical" ;
20+ const ARG_OPERANDS : & str = "operands" ;
1921
2022fn physical_path ( ) -> io:: Result < PathBuf > {
2123 // std::env::current_dir() is a thin wrapper around libc::getcwd().
@@ -110,6 +112,12 @@ fn logical_path() -> io::Result<PathBuf> {
110112#[ uucore:: main( no_signals) ]
111113pub fn uumain ( args : impl uucore:: Args ) -> UResult < ( ) > {
112114 let matches = uucore:: clap_localization:: handle_clap_result ( uu_app ( ) , args) ?;
115+
116+ // GNU pwd ignores any non-option operands but warns about them.
117+ if matches. contains_id ( ARG_OPERANDS ) {
118+ show_error ! ( "{}" , translate!( "pwd-ignoring-non-option-arguments" ) ) ;
119+ }
120+
113121 // if POSIXLY_CORRECT is set, we want to a logical resolution.
114122 // This produces a different output when doing mkdir -p a/b && ln -s a/b c && cd c && pwd
115123 // We should get c in this case instead of a/b at the end of the path
@@ -160,4 +168,10 @@ pub fn uu_app() -> Command {
160168 . help ( translate ! ( "pwd-help-physical" ) )
161169 . action ( ArgAction :: SetTrue ) ,
162170 )
171+ . arg (
172+ Arg :: new ( ARG_OPERANDS )
173+ . action ( ArgAction :: Append )
174+ . num_args ( 1 ..)
175+ . hide ( true ) ,
176+ )
163177}
0 commit comments