Skip to content
Snippets Groups Projects
Commit 936a9446 authored by Yorhel's avatar Yorhel
Browse files

Add -rr option to disable shell spawning

parent e4f211db
No related branches found
No related tags found
No related merge requests found
......@@ -35,8 +35,8 @@ I<FILE> is equivalent to C<->, the file is read from standard input.
For the sake of preventing a screw-up, the current version of ncdu will assume
that the directory information in the imported file does not represent the
filesystem on which the file is being imported. That is, the refresh and file
deletion options in the browser will be disabled.
filesystem on which the file is being imported. That is, the refresh, file
deletion and shell spawning options in the browser will be disabled.
=item I<dir>
......@@ -97,6 +97,16 @@ option has no effect when C<-o> is used, because there will not be a browser
interface in that case. It has no effect when C<-f> is used, either, because
the deletion feature is disabled in that case anyway.
WARNING: This option will only prevent deletion through the file browser. It is
still possible to spawn a shell from ncdu and delete or modify files from
there. To disable that feature as well, pass the C<-r> option twice (see
C<-rr>).
=item -rr
In addition to C<-r>, this will also disable the shell spawning feature of the
file browser.
=item --si
List sizes using base 10 prefixes, that is, powers of 1000 (KB, MB, etc), as
......
......@@ -417,8 +417,8 @@ int browse_key(int ch) {
info_show = 0;
break;
case 'd':
if(read_only || dir_import_active) {
message = read_only
if(read_only >= 1 || dir_import_active) {
message = read_only >= 1
? "File deletion disabled in read-only mode."
: "File deletion not available for imported directories.";
break;
......@@ -432,8 +432,10 @@ int browse_key(int ch) {
delete_init(sel, t);
break;
case 'b':
if(dir_import_active) {
message = "Shell feature not available for imported directories.";
if(read_only >= 2 || dir_import_active) {
message = read_only >= 2
? "Shell feature disabled in read-only mode."
: "Shell feature not available for imported directories.";
break;
}
shell_init();
......
......@@ -84,7 +84,7 @@ struct dir {
/* program state */
extern int pstate;
/* read-only flag */
/* read-only flag, 1+ = disable deletion, 2+ = also disable shell */
extern int read_only;
/* minimum screen update interval when calculating, in ms */
extern long update_delay;
......
......@@ -162,7 +162,7 @@ static void argv_parse(int argc, char **argv) {
printf("ncdu %s\n", PACKAGE_VERSION);
exit(0);
case 'x': dir_scan_smfs = 1; break;
case 'r': read_only = 1; break;
case 'r': read_only++; break;
case 's': si = 1; break;
case 'o': export = val; break;
case 'f': import = val; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment