add read permission check to cat command

This commit is contained in:
b1ek 2023-05-05 01:26:14 +10:00
parent 2f3ccae2f4
commit 3db714b153
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 3 additions and 0 deletions

View File

@ -23,6 +23,9 @@ module.exports = (argv, terminal) => {
terminal.writeln(`${argv[0]}: ${file}: no such file or directory`);
return;
}
if (!fs.accessSync(file, fs.constants.R_OK)) {
terminal.writeln(`${argv[0]}: read ${file}: access denied`);
}
const lines = fs.readFileSync(file).toString().split('\n');
if (numbers) {