File tree Expand file tree Collapse file tree 1 file changed +13
-15
lines changed
Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ pub fn alias(
1414 aliases : & mut BTreeMap < String , String > ,
1515 args : Vec < String > ,
1616) -> bool {
17- if args. len ( ) == 0 {
17+ if args. is_empty ( ) {
1818 for ( lhs, rhs) in aliases {
1919 println ! ( "alias {}='{}'" , lhs, rhs) ;
2020 }
@@ -68,24 +68,22 @@ pub fn set(args: Vec<String>, shell: &Rc<RefCell<Shell>>) -> bool {
6868}
6969
7070pub fn unalias ( aliases : & mut BTreeMap < String , String > , args : Vec < String > ) -> bool {
71- if args. len ( ) == 0 {
71+ if args. is_empty ( ) {
7272 eprintln ! ( "unalias: usage: unalias [-a] name [name ...]" ) ;
7373 false
74+ } else if args[ 0 ] == "-a" {
75+ aliases. clear ( ) ;
76+ true
7477 } else {
75- if args[ 0 ] == "-a" {
76- aliases. clear ( ) ;
77- true
78- } else {
79- let mut success = true ;
80- for arg in args {
81- if aliases. contains_key ( & arg) {
82- aliases. remove ( & arg) ;
83- } else {
84- eprintln ! ( "rush: unalias: {}: not found" , arg) ;
85- success = false ;
86- }
78+ let mut success = true ;
79+ for arg in args {
80+ if aliases. contains_key ( & arg) {
81+ aliases. remove ( & arg) ;
82+ } else {
83+ eprintln ! ( "rush: unalias: {}: not found" , arg) ;
84+ success = false ;
8785 }
88- success
8986 }
87+ success
9088 }
9189}
You can’t perform that action at this time.
0 commit comments