Skip to content

Commit 6d62956

Browse files
committed
I'm crushing your head!
1 parent 937634c commit 6d62956

3 files changed

Lines changed: 48 additions & 89 deletions

File tree

apps/Terminal.js

Lines changed: 47 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
/*@YSHFKSOK: This is necessary in order to ensure that the output from the following echo
2+
command is split into 3 arguments (rather than 1 argument with spaces in it):
13
4+
$ cat $(echo file1 file2 file3)
5+
6+
*/
27
//Notes«
38
/*4/3/25: Need to make sure that the verydumbhack @SAYEJSLSJ actually works for all
49
permutations of command line history heredoc editing. So test this out with multiple
@@ -1528,15 +1533,17 @@ log(val);
15281533
//Save to subLines and call scriptOut
15291534
if (this.subLines){
15301535
if (val instanceof Uint8Array) val = `Uint8Array(${val.length})`;
1531-
this.subLines.push(val);
1536+
// this.subLines.push(val);
1537+
//YSHFKSOK
1538+
this.subLines.push(val.split(" ").join("\n"));
15321539
return;
15331540
}
15341541
this.resp(val, opts);
15351542
}//»
15361543
//«Output helpers
15371544
err(str, opts={}){
15381545
opts.isErr=true;
1539-
this.resp(str, opts);
1546+
this.resp(`${this.name}: ${str}`, opts);
15401547
}
15411548
suc(str, opts={}){
15421549
opts.isSuc=true;
@@ -2256,22 +2263,25 @@ const com_loopctrl = class extends Com{//«
22562263
/*
22572264
Abort the command line, command sub or script that we are in.
22582265
*/
2259-
this.err(`${this.name}: ${num}: numeric argument required`);
2266+
// this.err(`${this.name}: ${num}: numeric argument required`);
2267+
this.err(`${num}: numeric argument required`);
22602268
// this.end({abortScript: true});
22612269
this.end({break: Infinity, abortScript: true});
22622270
return;
22632271
}
22642272
if (parseInt(num) < 1) {
22652273
//This breaks of all loops, so we do this.end({break: Infinity});
2266-
this.err(`${this.name}: ${num}: loop count out of range`);
2274+
// this.err(`${this.name}: ${num}: loop count out of range`);
2275+
this.err(`${num}: loop count out of range`);
22672276
this.doBreakInf = true;
22682277
return;
22692278
}
22702279
this.loopCnt = parseInt(num);
22712280
}
22722281
else this.loopCnt = 1;
22732282
if (this.args[1]){
2274-
this.err(`${this.name}: too many arguments`);
2283+
// this.err(`${this.name}: too many arguments`);
2284+
this.err(`too many arguments`);
22752285
this.doBreakInf = true;
22762286
}
22772287
}//»
@@ -3297,6 +3307,7 @@ for (let ent of this.val){
32973307
}
32983308

32993309
if (curfield) fields.push(curfield);
3310+
//log(fields);
33003311
this.fields = fields;
33013312
}//»
33023313

@@ -3597,7 +3608,9 @@ dup(){//«
35973608
}
35983609
return bq;
35993610
}//»
3600-
3611+
toString(){
3612+
return `\`${this.val.join("")}\``;
3613+
}
36013614
}//»
36023615
//XMKJDHE
36033616
const ParamSub = class extends Sequence{//«
@@ -3668,6 +3681,9 @@ dup(){//«
36683681
}
36693682
return com;
36703683
}//»
3684+
toString(){
3685+
return `$(${this.val.join("")})`;
3686+
}
36713687
}//»
36723688
const MathSub = class extends Sequence{//«
36733689

@@ -5801,83 +5817,34 @@ constructor(term){//«
58015817

58025818
fatal(mess){throw new Error(mess);}
58035819
async expandComsub(tok, opts){//«
5804-
//const expand_comsub=async(tok, shell, term)=>
5805-
//log(tok.val.join(""));
58065820
const{term}=this;
5807-
// const err = term.resperr;
5808-
const err=(mess)=>{
5809-
term.response(mess, {isErr: true});
5810-
};
5811-
// let s = tok.raw.join("");
5812-
//cwarn("COMSUB");
5813-
//log(tok);
5814-
//WSFOKGKDH
5815-
//let arr = tok.raw;
5816-
let arr = tok.val;
5817-
let s = '';
5818-
let len = arr.length;
5819-
//JLXOPKEUJ
5820-
for (let i=0; i < len; i++){
5821-
let ch = arr[i];
5822-
if (ch==="\\" && arr[i+1]==="\\"){
5823-
s+="\\";
5824-
i++;
5825-
}
5826-
else if (ch==="\\" && arr[i+1]==="`"){
5827-
s+="`";
5828-
i++;
5829-
}
5830-
else{
5831-
s+=ch;
5832-
}
5833-
}
5834-
/*«
5835-
let s='';
5836-
let vals = tok.val;
5837-
for (let ent of vals){
5838-
if (ent.expand) {
5839-
if (ent instanceof DQuote){
5840-
//Amazingly, having internal newline characters works here because they
5841-
//are treated like any other character inside of scanQuote()
5842-
//@DJJUTILJJ is where all the "others" characters (including newlines, "\n") are
5843-
//pushed into the quote's characters.
5844-
5845-
s+='"'+(await ent.expand(this, term, opts))+'"';
5846-
}
5847-
else if (ent instanceof DSQuote){
5848-
//Don't need to wrap it in $'...' again if we are actuall expanding it
5849-
// s+="'"+(await ent.expand(shell, term))+"'";
5850-
5851-
//Otherwise, wrap it up like we found it...
5852-
s+="$'"+(ent.toString())+"'";
5853-
}
5854-
else {
5855-
if (ent instanceof SQuote) {
5856-
s+="'"+ent.toString()+"'";
5857-
}
5858-
else {
5859-
//log(opts.env);
5860-
//log(ent.val);
5861-
//DOPMNRUK--------------------vvvvvvvvvv
5862-
s+=(await ent.expand(this, term, opts)).split("\n").join(" ");
5863-
}
5864-
}
5821+
const err=(mess)=>{
5822+
term.response(mess, {isErr: true});
5823+
};
5824+
let arr = tok.val;
5825+
let s = '';
5826+
let len = arr.length;
5827+
for (let i=0; i < len; i++){
5828+
let ch = arr[i];
5829+
if (ch==="\\" && arr[i+1]==="\\"){
5830+
s+="\\";
5831+
i++;
58655832
}
5866-
else {
5867-
if (ent instanceof SQuote){
5868-
s+="'"+ent.toString()+"'";
5869-
}
5870-
else {
5871-
s+=ent.toString();
5872-
}
5833+
else if (ch==="\\" && arr[i+1]==="`"){
5834+
s+="`";
5835+
i++;
5836+
}
5837+
else{
5838+
s+=ch;
58735839
}
58745840
}
5875-
»*/
5841+
//cwarn("COMSUB", s);
58765842
let sub_lines = [];
58775843
try{
58785844
//XMSKSLEO
5879-
58805845
let rv = await this.execute(s, {subLines: sub_lines, env: sdup(this.env), shell: this, term: this.term});
5846+
//log(sub_lines);
5847+
//log(sub_lines.join("\n"));
58815848
return sub_lines.join("\n");
58825849
}
58835850
catch(e){
@@ -6291,6 +6258,7 @@ return stdin;
62916258
}//»
62926259
async allExpansions(arr, shopts={}, opts={}){//«
62936260
//async allExpansions(arr, env, scriptName, scriptArgs, opts={}){
6261+
//log(arr);
62946262
const{env,scriptName,scriptArgs} = shopts;
62956263
const{term}=this;
62966264
const{isAssign}=opts;
@@ -6339,14 +6307,7 @@ for (let k=0; k < arr.length; k++){//field splitting«
63396307
let tok = arr[k];
63406308
if (tok.isWord) {
63416309
if (isAssign){
6342-
// let out=[];
6343-
// let out="";
6344-
// for (let field of tok.fields) out.push(...field.split("\n"));
6345-
// for (let field of tok.fields) out+=field+"\n";
6346-
// tok.val=out.join(" ");
6347-
//tok.val=out;
6348-
tok.val=tok.fields.join("\n");
6349-
//log(tok.val);
6310+
tok.val=tok.fields.join("\n");
63506311
}
63516312
else {
63526313
let{start} = tok;
@@ -6384,6 +6345,8 @@ for (let k=0; k < arr.length; k++){//quote removal«
63846345
}//»
63856346
//return {arr, inRedir: in_redir, outRedir: out_redir};
63866347
//return {arr, inRedir: in_redir, outRedir: out_redir};
6348+
//cwarn("ARR");
6349+
//log(arr);
63876350
return arr;
63886351
}//»
63896352
async tryImport(com, comword){//«
@@ -6445,11 +6408,9 @@ async makeCommand({assigns=[], name, args=[]}, opts){//«
64456408
const{term}=this;
64466409
const {loopNum, envReadLine, envRedirLines, envPipeInCb, scriptOut, stdin, stdinLns, outRedir, scriptArgs, scriptName, subLines, heredocScanner, env, isInteractive}=opts;
64476410
let comobj, usecomword;
6448-
//log(assigns);
64496411
let rv
64506412
let use_env;
64516413
if (assigns.length) {
6452-
// rv = await this.allExpansions(assigns, env, scriptName, scriptArgs, {isAssign: true});
64536414
rv = await this.allExpansions(assigns, opts, {isAssign: true});
64546415
if (isStr(rv)) return `sh: ${rv}`;
64556416
use_env = name?sdup(env):env;
@@ -6478,8 +6439,8 @@ async makeCommand({assigns=[], name, args=[]}, opts){//«
64786439
return new NoCom(com_env);
64796440
}
64806441
let arr = [name, ...args];
6481-
// rv = await this.allExpansions(arr, env, scriptName, scriptArgs);
64826442
rv = await this.allExpansions(arr, opts);
6443+
//log(rv);
64836444
if (isStr(rv)) return `sh: ${rv}`;
64846445
{
64856446
let hold = arr;
@@ -6686,7 +6647,6 @@ log(red);
66866647
};
66876648
comopts.envReadLine = env_readline;
66886649
}//»
6689-
66906650
if (com_ast.simple_command && com_ast.simple_command.name && com_ast.simple_command.name.toString().match(/\x2f/)){
66916651
com = await this.makeScriptCom(com_ast, comopts);
66926652
}

coms/fs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ run:
465465
this.ok();
466466
}
467467
}//»
468-
469468
async doTermLoop(){//«
470469
while (true){
471470
let ln = await this.readLine();

list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["README.md/2548","apps",["Audio.js/4093","BinView.js/9814","Folder.js/10944","Help.js/979","MediaPlayer.js/2074","Meta.js/2279","Music.js/4844","NN.js/1136","Poker.js/41043","Something.js/32","Terminal.js/257630","TextEdit.js/5174","WorkMan.js/3808","YourApp.js/418","dev",["Ermpt.js/507","Grammar.js/15536","HTML.js/1348","Hands.js/15575","Kuhn.js/7362","Launcher.js/20502","NewShell.js/84972","Player.js/2121","Poker5.js/4891","TakePicture.js/3475","Worker.js/1195","audio",["Blah.js/3601","MakeSomeBass.js/5879","Midi.js/3953","Noise.js/2048","Vowels.js/13141","cool",["RandomWalk.js/5090"],"zsave",["Faust.js/35023","Jazzed.js/18165","Jazzed2.js/31797","Karplus.js/30845","Noisecraft.js/11936"]],"svg",["SVG1.js/12599","SVG2.js/18599"],"zold",["Poker.js/26967","Poker2.js/76136","Poker3.js/65113","Poker4.js/36503"]],"games",["Arcade.js/12599"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/44729"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["ImageView.js/2696","Unicoder.js/16896"]],"bin",["ALLLIST/106","APPLIST/104","DIRGET/47","DOBEAUTIFY/71","DOLINKS/330","DOZIP/801","GITUP/396","MKLOTWLIST/136","MKSYMLINKS/487","PYSERV/84","SSLPYSERV.py/528","dojsbeautify/71","js",["getdir.js/665"],"vallgrep/398","vvallgrep/544"],"coms",["audio.js/1766","esprima.js/171824","extra.js/10807","fs.js/26758","mail.js/43901","shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/1982","yt.js/66863","zhold",["mail.js/22724"]],"doc",["EDITING/1847","START_HERE/2609","apis",["imap-flow.js/104043","imapflow.txt/38670"],"concepts",["DATA_IPC/4482"],"dev",["CHANGES/2853","DESK/63027","FS/7462","TERMINAL/149463","VIM/16037"]],"index.html/1184","init",["my_setup.js/1264"],"local",["_poker",["001/19229","003/23581","FLOP_EV_1.json/3312805","FLOP_EV_2.json/3389041","FLOP_EV_3.json/3719620","FLOP_EV_4.json/3503737","FLOP_EV_5.js/3470856","RIVER_EV_1.json/38068483","RIVER_EV_2.json/39745965","RIVER_EV_3.json/44070681","RIVER_EV_4.json/41514544","RIVER_EV_5.json/41100610","TURN_EV_1.json/17598825","TURN_EV_2.json/18032587","TURN_EV_3.json/19787973","TURN_EV_4.json/18622556","TURN_EV_5.json/18423232"]],"mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9708","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"term",["email.js/10406","less.js/19675","log.js/13262","vim.js/150516"],"util",["math.js/12125","nn",["snake",["worker.js/29373"]],"pretty.js/93856","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7198","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"sys",["config.js/8812","desk.js/216683","fs.js/66130","util.js/20006"],"www",["blog.css/181","config",["bashrc.txt/692","desert.vim/2952","nano-hack.txt/2324","vimrc.txt/1443"],"desk.css/1898","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]],"zzhold",["DESK/1306","SHELL/17941","noisecraft",["audiograph.js/22588","audioview.js/5086","audioworklet.js/1319","compiler.js/15169","dialog.js/3578","editor.js/72623","eventable.js/965","knob.js/10041","midi.js/2044","model.js/57480","music.js/7887","synth.js/6652","utils.js/6876","zhold",["audioworklet.js/2980","compiler.js/37421","model.js/57645"]],"writes",["RUNTIME.js/4583","Terminal.js/80662"]]]
1+
["README.md/2548","apps",["Audio.js/4093","BinView.js/9814","Folder.js/10944","Help.js/979","MediaPlayer.js/2074","Meta.js/2279","Music.js/4844","NN.js/1136","Poker.js/41043","Something.js/32","Terminal.js/256677","TextEdit.js/5174","WorkMan.js/3808","YourApp.js/418","dev",["Ermpt.js/507","Grammar.js/15536","HTML.js/1348","Hands.js/15575","Kuhn.js/7362","Launcher.js/20502","NewShell.js/84972","Player.js/2121","Poker5.js/4891","TakePicture.js/3475","Worker.js/1195","audio",["Blah.js/3601","MakeSomeBass.js/5879","Midi.js/3953","Noise.js/2048","Vowels.js/13141","cool",["RandomWalk.js/5090"],"zsave",["Faust.js/35023","Jazzed.js/18165","Jazzed2.js/31797","Karplus.js/30845","Noisecraft.js/11936"]],"svg",["SVG1.js/12599","SVG2.js/18599"],"zold",["Poker.js/26967","Poker2.js/76136","Poker3.js/65113","Poker4.js/36503"]],"games",["Arcade.js/12599"],"hw",["MidiCtl.js/3691"],"media",["2Cameras.js/3258","Camera.js/3673","MediaPlayer.js/16115","VideoCutter.js/44729"],"template",["Basic.js/489","Template.js/396","WebAudio.js/2877"],"util",["ImageView.js/2696","Unicoder.js/16896"]],"bin",["ALLLIST/106","APPLIST/104","DIRGET/47","DOBEAUTIFY/71","DOLINKS/330","DOZIP/801","GITUP/396","MKLOTWLIST/136","MKSYMLINKS/487","PYSERV/84","SSLPYSERV.py/528","dojsbeautify/71","js",["getdir.js/665"],"vallgrep/398","vvallgrep/544"],"coms",["audio.js/1766","esprima.js/171824","extra.js/10807","fs.js/26757","mail.js/43901","shell.js/175037","template.js/336","test",["dummy.js/21"],"test.js/1982","yt.js/66863","zhold",["mail.js/22724"]],"doc",["EDITING/1847","START_HERE/2609","apis",["imap-flow.js/104043","imapflow.txt/38670"],"concepts",["DATA_IPC/4482"],"dev",["CHANGES/2853","DESK/63027","FS/7462","TERMINAL/149463","VIM/16037"]],"index.html/1184","init",["my_setup.js/1264"],"local",["_poker",["001/19229","003/23581","FLOP_EV_1.json/3312805","FLOP_EV_2.json/3389041","FLOP_EV_3.json/3719620","FLOP_EV_4.json/3503737","FLOP_EV_5.js/3470856","RIVER_EV_1.json/38068483","RIVER_EV_2.json/39745965","RIVER_EV_3.json/44070681","RIVER_EV_4.json/41514544","RIVER_EV_5.json/41100610","TURN_EV_1.json/17598825","TURN_EV_2.json/18032587","TURN_EV_3.json/19787973","TURN_EV_4.json/18622556","TURN_EV_5.json/18423232"]],"mods",["audio",["multi_freq_worklet.js/1502","random_walk_worklet.js/3039"],"games",["GBEmulator.js/9708","NESEmulator.js/222309","binjgb.wasm/87232"],"help",["shell.js/3591"],"hw",["midi.js/2323"],"term",["email.js/10406","less.js/19675","log.js/13262","vim.js/150516"],"util",["math.js/12125","nn",["snake",["worker.js/29373"]],"pretty.js/93856","walt.js/204893","wasm.js/42764","wasmparser.js/34331","webmparser.js/58730"],"workers",["poker.js/37420"]],"node",["server.js/7198","svcs",["imap.js/17772","mount.js/16553","smtp.js/1359","template.js/1831","ws.js/2156","ytdl.js/11982"]],"sys",["config.js/8812","desk.js/216683","fs.js/66130","util.js/20006"],"www",["blog.css/181","config",["bashrc.txt/692","desert.vim/2952","nano-hack.txt/2324","vimrc.txt/1443"],"desk.css/1898","docs",["blog-template.html/291","help.html/9104","what-it-is.html/4370"],"examples",["test.sh/66"],"favicon.ico/15086","lotw256.png/41075","lotw48.png/2966","stuff",["noise.html/1669"]],"zzhold",["DESK/1306","SHELL/17941","noisecraft",["audiograph.js/22588","audioview.js/5086","audioworklet.js/1319","compiler.js/15169","dialog.js/3578","editor.js/72623","eventable.js/965","knob.js/10041","midi.js/2044","model.js/57480","music.js/7887","synth.js/6652","utils.js/6876","zhold",["audioworklet.js/2980","compiler.js/37421","model.js/57645"]],"writes",["RUNTIME.js/4583","Terminal.js/80662"]]]

0 commit comments

Comments
 (0)