@@ -739,6 +739,60 @@ describe(`Shell`, () => {
739
739
} ) ;
740
740
} ) ;
741
741
742
+ it ( `shouldn't affect unrelated commands` , async ( ) => {
743
+ await xfs . mktempPromise ( async tmpDir => {
744
+ const file = ppath . join ( tmpDir , `file` as Filename ) ;
745
+
746
+ await expect ( bufferResult (
747
+ `echo "hello world" > "${ file } "; echo foo` ,
748
+ ) ) . resolves . toMatchObject ( {
749
+ stdout : `foo\n` ,
750
+ } ) ;
751
+
752
+ await expect ( xfs . readFilePromise ( file , `utf8` ) ) . resolves . toEqual ( `hello world\n` ) ;
753
+ } ) ;
754
+
755
+ await xfs . mktempPromise ( async tmpDir => {
756
+ const file = ppath . join ( tmpDir , `file` as Filename ) ;
757
+
758
+ await expect ( bufferResult (
759
+ `echo "hello world" > "${ file } " && echo foo` ,
760
+ ) ) . resolves . toMatchObject ( {
761
+ stdout : `foo\n` ,
762
+ } ) ;
763
+
764
+ await expect ( xfs . readFilePromise ( file , `utf8` ) ) . resolves . toEqual ( `hello world\n` ) ;
765
+ } ) ;
766
+ } ) ;
767
+
768
+ it ( `shouldn't do weird stuff when piping a builtin redirection` , async ( ) => {
769
+ await xfs . mktempPromise ( async tmpDir => {
770
+ const file1 = ppath . join ( tmpDir , `file1` as Filename ) ;
771
+ const file2 = ppath . join ( tmpDir , `file2` as Filename ) ;
772
+
773
+ await expect ( bufferResult (
774
+ `echo "hello world" > "${ file1 } " | echo "foo bar" > "${ file2 } "; echo test` ,
775
+ ) ) . resolves . toMatchObject ( {
776
+ stdout : `test\n` ,
777
+ } ) ;
778
+
779
+ await expect ( xfs . readFilePromise ( file1 , `utf8` ) ) . resolves . toEqual ( `hello world\n` ) ;
780
+ await expect ( xfs . readFilePromise ( file2 , `utf8` ) ) . resolves . toEqual ( `foo bar\n` ) ;
781
+ } ) ;
782
+
783
+ await xfs . mktempPromise ( async tmpDir => {
784
+ const file = ppath . join ( tmpDir , `file` as Filename ) ;
785
+
786
+ await expect ( bufferResult (
787
+ `echo "hello world" > "${ file } " && echo foo` ,
788
+ ) ) . resolves . toMatchObject ( {
789
+ stdout : `foo\n` ,
790
+ } ) ;
791
+
792
+ await expect ( xfs . readFilePromise ( file , `utf8` ) ) . resolves . toEqual ( `hello world\n` ) ;
793
+ } ) ;
794
+ } ) ;
795
+
742
796
it ( `should support output redirections from fd (stdout)` , async ( ) => {
743
797
await xfs . mktempPromise ( async tmpDir => {
744
798
const file = ppath . join ( tmpDir , `file` as Filename ) ;
0 commit comments