@@ -823,6 +823,11 @@ impl Executor {
823
823
let acc = self . pop_stack ( ) . get_string ( ) ;
824
824
let list = self . pop_stack ( ) . get_list ( ) ;
825
825
826
+ self . memory
827
+ . entry ( acc. clone ( ) )
828
+ . and_modify ( |value| * value = Type :: String ( "" . to_string ( ) ) )
829
+ . or_insert ( Type :: String ( "" . to_string ( ) ) ) ;
830
+
826
831
for x in list. iter ( ) {
827
832
self . memory
828
833
. entry ( now. clone ( ) )
@@ -983,17 +988,23 @@ impl Executor {
983
988
984
989
// Open the file or url
985
990
"open" => {
986
- if let Err ( e) = opener:: open ( self . pop_stack ( ) . get_string ( ) ) {
991
+ let name = self . pop_stack ( ) . get_string ( ) ;
992
+ if let Err ( e) = opener:: open ( name. clone ( ) ) {
987
993
self . log_print ( format ! ( "Error! {e}\n " ) ) ;
988
994
self . stack . push ( Type :: Error ( "open" . to_string ( ) ) ) ;
995
+ } else {
996
+ self . stack . push ( Type :: String ( name) )
989
997
}
990
998
}
991
999
992
1000
// Change current directory
993
1001
"cd" => {
994
- if let Err ( err) = std:: env:: set_current_dir ( self . pop_stack ( ) . get_string ( ) ) {
1002
+ let name = self . pop_stack ( ) . get_string ( ) ;
1003
+ if let Err ( err) = std:: env:: set_current_dir ( name. clone ( ) ) {
995
1004
self . log_print ( format ! ( "Error! {}\n " , err) ) ;
996
1005
self . stack . push ( Type :: Error ( "cd" . to_string ( ) ) ) ;
1006
+ } else {
1007
+ self . stack . push ( Type :: String ( name) )
997
1008
}
998
1009
}
999
1010
@@ -1009,33 +1020,41 @@ impl Executor {
1009
1020
// Make directory
1010
1021
"mkdir" => {
1011
1022
let name = self . pop_stack ( ) . get_string ( ) ;
1012
- if let Err ( e) = fs:: create_dir ( name) {
1023
+ if let Err ( e) = fs:: create_dir ( name. clone ( ) ) {
1013
1024
self . log_print ( format ! ( "Error! {e}\n " ) ) ;
1014
1025
self . stack . push ( Type :: Error ( "mkdir" . to_string ( ) ) ) ;
1026
+ } else {
1027
+ self . stack . push ( Type :: String ( name) )
1015
1028
}
1016
1029
}
1017
1030
1018
1031
// Remove item
1019
1032
"rm" => {
1020
1033
let name = self . pop_stack ( ) . get_string ( ) ;
1021
1034
if Path :: new ( name. as_str ( ) ) . is_dir ( ) {
1022
- if let Err ( e) = fs:: remove_dir ( name) {
1035
+ if let Err ( e) = fs:: remove_dir ( name. clone ( ) ) {
1023
1036
self . log_print ( format ! ( "Error! {e}\n " ) ) ;
1024
1037
self . stack . push ( Type :: Error ( "rm" . to_string ( ) ) ) ;
1038
+ } else {
1039
+ self . stack . push ( Type :: String ( name) )
1025
1040
}
1026
- } else if let Err ( e) = fs:: remove_file ( name) {
1041
+ } else if let Err ( e) = fs:: remove_file ( name. clone ( ) ) {
1027
1042
self . log_print ( format ! ( "Error! {e}\n " ) ) ;
1028
1043
self . stack . push ( Type :: Error ( "rm" . to_string ( ) ) ) ;
1044
+ } else {
1045
+ self . stack . push ( Type :: String ( name) )
1029
1046
}
1030
1047
}
1031
1048
1032
1049
// Rename item
1033
1050
"rename" => {
1034
1051
let to = self . pop_stack ( ) . get_string ( ) ;
1035
1052
let from = self . pop_stack ( ) . get_string ( ) ;
1036
- if let Err ( e) = fs:: rename ( from, to) {
1053
+ if let Err ( e) = fs:: rename ( from, to. clone ( ) ) {
1037
1054
self . log_print ( format ! ( "Error! {e}\n " ) ) ;
1038
1055
self . stack . push ( Type :: Error ( "rename" . to_string ( ) ) ) ;
1056
+ } else {
1057
+ self . stack . push ( Type :: String ( to) )
1039
1058
}
1040
1059
}
1041
1060
0 commit comments