@@ -588,32 +588,6 @@ impl Executor {
588588 thread:: spawn ( move || executor. evaluate_program ( code) ) ;
589589 }
590590
591- // シェルコマンドを実行
592- "shell" => {
593- let ps = PsScriptBuilder :: new ( )
594- . no_profile ( true )
595- . non_interactive ( true )
596- . hidden ( false )
597- . print_commands ( false )
598- . build ( ) ;
599- let _ = ps. run (
600- "[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding('utf-8')" ,
601- ) ;
602- let result = ps. run ( self . pop_stack ( ) . get_string ( ) . as_str ( ) ) ;
603- match result {
604- Ok ( i) => self . stack . push ( Type :: String (
605- i. stdout ( )
606- . unwrap_or ( "" . to_string ( ) )
607- . as_str ( )
608- . trim ( )
609- . to_string ( ) ,
610- ) ) ,
611- Err ( _) => {
612- self . log_print ( "エラー! シェルスクリプトの実行に失敗しました\n " . to_string ( ) )
613- }
614- }
615- }
616-
617591 // プロセスを終了
618592 "exit" => {
619593 let status = self . pop_stack ( ) . get_number ( ) ;
@@ -880,7 +854,7 @@ impl Executor {
880854 // 一定時間スリープ
881855 "sleep" => sleep ( Duration :: from_secs_f64 ( self . pop_stack ( ) . get_number ( ) ) ) ,
882856
883- // Web系処理
857+ // 外部連携処理
884858
885859 //HTTPリクエストを送る
886860 "request" => {
@@ -890,6 +864,39 @@ impl Executor {
890864 ) ) ;
891865 }
892866
867+ // ファイルを開く
868+ "open" => {
869+ let _result = std:: process:: Command :: new ( "cmd" )
870+ . args ( & [ "/C" , "start" , "" , self . pop_stack ( ) . get_string ( ) . as_str ( ) ] )
871+ . spawn ( ) ;
872+ }
873+
874+ // シェルコマンドを実行
875+ "shell" => {
876+ let ps = PsScriptBuilder :: new ( )
877+ . no_profile ( true )
878+ . non_interactive ( true )
879+ . hidden ( false )
880+ . print_commands ( false )
881+ . build ( ) ;
882+ let _ = ps. run (
883+ "[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding('utf-8')" ,
884+ ) ;
885+ let result = ps. run ( self . pop_stack ( ) . get_string ( ) . as_str ( ) ) ;
886+ match result {
887+ Ok ( i) => self . stack . push ( Type :: String (
888+ i. stdout ( )
889+ . unwrap_or ( "" . to_string ( ) )
890+ . as_str ( )
891+ . trim ( )
892+ . to_string ( ) ,
893+ ) ) ,
894+ Err ( _) => {
895+ self . log_print ( "エラー! シェルスクリプトの実行に失敗しました\n " . to_string ( ) )
896+ }
897+ }
898+ }
899+
893900 // コマンドとして認識されない場合は文字列とする
894901 _ => self . stack . push ( Type :: String ( command) ) ,
895902 }
0 commit comments