Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Await stdio writes in all coreutils #69

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/puter-shell/coreutils/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// INCONST: called 'path' instead of 'path_' elsewhere
import path_ from "path-browserify";
import { SHELL_VERSIONS } from "../../meta/versions.js";

function printVersion(ctx, version) {
ctx.externs.out.write(`\x1B[35;1m[v${version.v}]\x1B[0m\n`);
async function printVersion(ctx, version) {
await ctx.externs.out.write(`\x1B[35;1m[v${version.v}]\x1B[0m\n`);
for ( const change of version.changes ) {
ctx.externs.out.write(`\x1B[32;1m+\x1B[0m ${change}\n`);
await ctx.externs.out.write(`\x1B[32;1m+\x1B[0m ${change}\n`);
}
}

Expand All @@ -42,12 +40,12 @@ export default {
},
execute: async ctx => {
if (ctx.locals.values.latest) {
printVersion(ctx, SHELL_VERSIONS[0]);
await printVersion(ctx, SHELL_VERSIONS[0]);
return;
}

for ( const version of SHELL_VERSIONS.toReversed() ) {
printVersion(ctx, version);
await printVersion(ctx, version);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/puter-shell/coreutils/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ export default {
allowPositionals: false
},
execute: async ctx => {
ctx.externs.out.write('\x1B[H\x1B[2J');
await ctx.externs.out.write('\x1B[H\x1B[2J');
}
};
6 changes: 3 additions & 3 deletions src/puter-shell/coreutils/cp.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ export default {
const { filesystem } = ctx.platform;

if ( positionals.length < 1 ) {
err.write('cp: missing file operand\n');
await err.write('cp: missing file operand\n');
throw new Exit(1);
}

const srcRelPath = positionals.shift();

if ( positionals.length < 1 ) {
const aft = positionals[0];
err.write(`cp: missing destination file operand after '${aft}'\n`);
await err.write(`cp: missing destination file operand after '${aft}'\n`);
throw new Exit(1);
}

Expand All @@ -59,7 +59,7 @@ export default {

const srcStat = await filesystem.stat(srcAbsPath);
if ( srcStat && srcStat.is_dir && ! values.recursive ) {
err.write(`cp: -R not specified; skipping directory '${srcRelPath}'\n`);
await err.write(`cp: -R not specified; skipping directory '${srcRelPath}'\n`);
throw new Exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/puter-shell/coreutils/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default {
? [pwd] : positionals ;

const showHeadings = paths.length > 1 ? async ({ i, path }) => {
if ( i !== 0 ) ctx.externs.out.write('\n');
if ( i !== 0 ) await ctx.externs.out.write('\n');
await ctx.externs.out.write(path + ':\n');
} : () => {};

Expand Down
2 changes: 1 addition & 1 deletion src/puter-shell/coreutils/neofetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default {
lines[15] += '\x1B[0m';

for ( const line of lines ) {
ctx.externs.out.write(line + '\n');
await ctx.externs.out.write(line + '\n');
}
}
}
2 changes: 1 addition & 1 deletion src/puter-shell/coreutils/sample-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default {
}

console.log('before writing');
ctx.externs.out.write('Hello, World!\n');
await ctx.externs.out.write('Hello, World!\n');
console.log('after writing');
}
}