@@ -49,7 +49,7 @@ const widgets = NS.api.widgets;
4949const { pathToNode} = fsapi ;
5050const { E_SUC , E_ERR } = SHELL_ERROR_CODES ;
5151//const {Com, ErrCom, make_error_com} = comClasses;
52- const { SimpleCommand } = ShellMod . comClasses ;
52+ const { Com } = ShellMod . comClasses ;
5353const { Desk} = LOTW ;
5454const { make_icon_if_new} = Desk ;
5555//»
@@ -62,7 +62,8 @@ const allow_write_locked = false;
6262
6363//Funcs«
6464
65- const get_file_lines_from_args = async ( args , term , errcb ) => { //«
65+ const get_file_lines_from_args = async ( args , cur_dir , errcb ) => { //«
66+ //const get_file_lines_from_args = async(args, term, errcb)=>{
6667 let err = [ ] ;
6768 let out = [ ] ;
6869 const fullterr = ( arg ) => {
@@ -71,7 +72,7 @@ const get_file_lines_from_args = async(args, term, errcb)=>{//«
7172 } ;
7273 let fullpath ;
7374 while ( args . length ) {
74- fullpath = normPath ( args . shift ( ) , term . cur_dir ) ;
75+ fullpath = normPath ( args . shift ( ) , cur_dir ) ;
7576 let node = await fsapi . pathToNode ( fullpath ) ;
7677 if ( ! node ) {
7778 fullterr ( `no such file or directory` ) ;
@@ -111,7 +112,7 @@ const get_file_lines_from_args = async(args, term, errcb)=>{//«
111112//»
112113
113114//Commands«
114- const Com = SimpleCommand ;
115+ // const Com = SimpleCommand;
115116/*«
116117const com_ = class extends Com{
117118async init(){
@@ -180,7 +181,7 @@ async init(){//«
180181 if ( ! f ) {
181182 return ;
182183 }
183- let node = await f . toNode ( this . term ) ;
184+ let node = await f . toNode ( this . env . cwd ) ;
184185 if ( ! node ) {
185186 return no ( `${ f } : Not found` ) ;
186187 }
@@ -296,7 +297,7 @@ async init(){//«
296297 }
297298 }
298299 else {
299- let fullpath = normPath ( path , this . term . cur_dir ) ;
300+ let fullpath = normPath ( path , this . env . cwd . cwd ) ;
300301 let node = await fsapi . pathToNode ( fullpath ) ;
301302 if ( ! node ) {
302303 return this . no ( `${ fullpath } : no such file or directory` ) ;
@@ -383,7 +384,7 @@ async init(){//«
383384 let use_mod_name ;
384385 if ( opts . d ) {
385386 use_mod_name = "local.dev.vim" ;
386- let txt = await opts . d . toText ( term ) ;
387+ let txt = await opts . d . toText ( this . env . cwd ) ;
387388 if ( ! isStr ( txt ) ) return this . no ( `${ opts . d } : file not found` ) ;
388389 let url = URL . createObjectURL ( new Blob ( [ `(function(){"use strict";${ txt } })()` ] ) ) ;
389390 let scr ;
@@ -421,7 +422,7 @@ return {mess: "YIM ON THE YIM YIM YIM", type: 2};
421422 let linkNode ;
422423 let symbols ;
423424 if ( opts . symbols ) { //«
424- let rv = await opts . symbols . toText ( term ) ;
425+ let rv = await opts . symbols . toText ( this . env . cwd ) ;
425426 if ( ! rv ) return this . no ( `${ opts . symbols } : symbol file not found` ) ;
426427 rv = rv . split ( "\n" ) ;
427428 symbols = [ ] ;
@@ -439,7 +440,7 @@ return {mess: "YIM ON THE YIM YIM YIM", type: 2};
439440 else val = "" ;
440441 }
441442 else {
442- fullpath = normPath ( path , term . cur_dir ) ;
443+ fullpath = normPath ( path , this . env . cwd . cwd ) ;
443444 node = await fsapi . pathToNode ( fullpath ) ;
444445 if ( ! node ) {
445446 let badlink = await fsapi . pathToNode ( fullpath , true ) ;
@@ -516,26 +517,6 @@ cancel(){//«
516517} //»
517518
518519} //»
519- const com_cat = class extends Com { //«
520- async run ( ) { //«
521- if ( this . args . length ) {
522- let txt ;
523- while ( txt = await this . nextArgAsText ( ) ) {
524- if ( ! isErr ( txt ) ) this . out ( txt . join ( "\n" ) ) ;
525- }
526- this . nok ( ) ;
527- return ;
528- }
529- let rv ;
530- while ( true ) {
531- rv = await this . readStdinChunk ( ) ;
532- if ( isEOF ( rv ) ) {
533- return this . ok ( ) ;
534- }
535- this . out ( rv ) ;
536- }
537- } //»
538- } ; //»
539520const com_grep = class extends Com { //«
540521//#re;
541522
@@ -575,7 +556,7 @@ async run(){//«
575556 this . ok ( ) ;
576557 return ;
577558 }
578- let rv = await get_file_lines_from_args ( args , this . term , err ) ;
559+ let rv = await get_file_lines_from_args ( args , this . env . cwd . cwd , err ) ;
579560// if (rv.err && rv.err.length) err(rv.err);
580561 if ( rv . out && rv . out . length ) this . doGrep ( rv . out ) ;
581562 have_error ?this . no ( ) :this . ok ( ) ;
@@ -701,7 +682,7 @@ async run(){
701682 have_error = true ;
702683 this . err ( mess ) ;
703684 } ;
704- let rv = await get_file_lines_from_args ( args , this . term , err ) ;
685+ let rv = await get_file_lines_from_args ( args , this . env . cwd . cwd , err ) ;
705686// if (rv.err && rv.err.length) err(rv.err);
706687 if ( rv . out && rv . out . length ) this . doWC ( rv . out ) ;
707688 this . sendCount ( ) ;
@@ -740,7 +721,7 @@ async run(){
740721 } ;
741722 while ( args . length ) {
742723 let path = args . shift ( ) ;
743- let fullpath = normPath ( path , term . cur_dir ) ;
724+ let fullpath = normPath ( path , this . env . cwd . cwd ) ;
744725 let node = await pathToNode ( fullpath ) ;
745726 if ( node ) {
746727 continue ;
@@ -785,7 +766,7 @@ const com_mv = class extends Com{//«
785766 have_error = true ;
786767 this . err ( mess ) ;
787768 } ;
788- await fsapi . comMv ( args , { if_cp : false , exports : { cberr : err , werr : err , cur_dir : term . cur_dir , termobj : term } } ) ;
769+ await fsapi . comMv ( args , { if_cp : false , exports : { cberr : err , werr : err , cur_dir : this . env . cwd . cwd , termobj : term } } ) ;
789770 have_error ?this . no ( ) :this . ok ( ) ;
790771 }
791772} //»
@@ -804,7 +785,7 @@ const com_cp = class extends Com{//«
804785 have_error = true ;
805786 this . err ( mess ) ;
806787 } ;
807- await fsapi . comMv ( args , { if_cp : true , exports : { cberr : err , werr : err , cur_dir : term . cur_dir , termobj : term } } ) ;
788+ await fsapi . comMv ( args , { if_cp : true , exports : { cberr : err , werr : err , cur_dir : this . env . cwd . cwd , termobj : term } } ) ;
808789 have_error ?this . no ( ) :this . ok ( ) ;
809790 }
810791} //»
@@ -819,7 +800,7 @@ async run(){
819800 }
820801 while ( args . length ) {
821802 let path = args . shift ( ) ;
822- let fullpath = normPath ( path , term . cur_dir ) ;
803+ let fullpath = normPath ( path , this . env . cwd . cwd ) ;
823804 let node = await fsapi . pathToNode ( fullpath ) ;
824805 if ( node ) {
825806 err ( `${ fullpath } : the file or directory exists` ) ;
@@ -875,7 +856,7 @@ async run(){
875856 err ( "missing operand" ) ;
876857 }
877858 else {
878- await fsapi . doFsRm ( args , err , { CWD : term . cur_dir , FULLDIRS : false , dirsOnly : true } ) ;
859+ await fsapi . doFsRm ( args , err , { CWD : this . env . cwd . cwd , FULLDIRS : false , dirsOnly : true } ) ;
879860 }
880861
881862 have_error ?this . no ( ) :this . ok ( ) ;
@@ -898,7 +879,7 @@ async run(){
898879 }
899880 else {
900881 let okargs = [ ] ;
901- let cwd = term . cur_dir
882+ let cwd = this . env . cwd . cwd
902883 for ( let path of args ) {
903884 let fullpath = normPath ( path , cwd ) ;
904885 let node = await fsapi . pathToNode ( fullpath , true ) ;
@@ -939,7 +920,7 @@ async run(){
939920 let target = args . shift ( ) ;
940921 let path = args . shift ( ) ;
941922
942- let target_node = await fsapi . pathToNode ( normPath ( target , term . cur_dir ) ) ;
923+ let target_node = await fsapi . pathToNode ( normPath ( target , this . env . cwd . cwd ) ) ;
943924 if ( ! target_node ) {
944925 return err ( "the target does not exist" ) ;
945926 }
@@ -959,7 +940,7 @@ async run(){
959940 return err ( `${ target_node . par . fullpath } : permission denied` ) ;
960941 }
961942
962- let fullpath = normPath ( path , term . cur_dir ) ;
943+ let fullpath = normPath ( path , this . env . cwd . cwd ) ;
963944 let node = await fsapi . pathToNode ( fullpath , true ) ;
964945 if ( node ) {
965946 return err ( `${ path } : already exists` ) ;
@@ -1007,7 +988,7 @@ async run(){
1007988 let target = args . shift ( ) ;
1008989 let path = args . shift ( ) ;
1009990
1010- let fullpath = normPath ( path , this . term . cur_dir ) ;
991+ let fullpath = normPath ( path , this . env . cwd . cwd ) ;
1011992 let node = await fsapi . pathToNode ( fullpath , true ) ;
1012993 if ( node ) {
1013994 return err ( `${ path } : already exists` ) ;
@@ -1026,7 +1007,7 @@ async run(){
10261007 if ( ! parnode . okWrite ) {
10271008 return err ( `${ path } : permission denied` ) ;
10281009 }
1029- let newnode = await fsapi . makeLink ( parnode , fname , target , normPath ( target , this . term . cur_dir ) ) ;
1010+ let newnode = await fsapi . makeLink ( parnode , fname , target , normPath ( target , this . env . cwd . cwd ) ) ;
10301011 if ( ! newnode ) {
10311012 return err ( `${ path } : the link could not be created` ) ;
10321013 }
@@ -1069,7 +1050,7 @@ async run(){
10691050 const { args} = this ;
10701051 if ( this . killed || ! args . length ) return ;
10711052 let path = args . shift ( ) ;
1072- let fullpath = normPath ( path , this . term . cur_dir ) ;
1053+ let fullpath = normPath ( path , this . env . cwd . cwd ) ;
10731054 let node = await fsapi . pathToNode ( fullpath ) ;
10741055 if ( ! node ) {
10751056 this . no ( `${ fullpath } : the file could not be found` ) ;
@@ -1109,7 +1090,7 @@ async run(){
11091090 const { args, term} = this ;
11101091 let out = [ ] ;
11111092 let nargs = args . length ;
1112- let cur_dir = term . cur_dir ;
1093+ let cur_dir = this . env . cwd . cwd ;
11131094 if ( nargs ) {
11141095 for ( let arg of args ) {
11151096 if ( nargs > 1 ) out . push ( `${ arg } :` ) ;
@@ -1237,7 +1218,7 @@ wc: com_wc,
12371218grep : com_grep ,
12381219dl : com_dl ,
12391220less :com_less ,
1240- cat :com_cat ,
1221+ // cat:com_cat,
12411222mkdir : com_mkdir ,
12421223rmdir : com_rmdir ,
12431224mv :com_mv ,
0 commit comments