I have a file on disk which contains some text I want to display on the screen. You can do it like this:dialog --yesno `cat FILE` 10 100However, I'm concerned that if FILE becomes large, I'm likely to exceed the command length limits of the shell. Is there some other way to accomplish this task?I want to display the contents of the file so the user can scroll through it (if it's really long), and then select what to do next. (I've relabelled the yes and no buttons to something more meaningful.) Presumably trying to pipe six pages of text through the command line like this is going to break.
Display file using Dialog
files;dialog
Looking at the man page for this there does seem to be any way to avoid passing the text as an argument - there appears to be no way to pipe the data in or have dialog read directly from the file. However, you could limit the size of the argument using head. On most Linux systems the maximum size for a single argument is 32KiB, so you could do:dialog --max-input 32768 --yesno $(head -c 32K FILE) 10 100The maximum size for a single argument is defined by MAX_ARG_STRLEN which you will find in /usr/include/linux/binfmts.h if you have kernel headers installed. Usually the value is PAGE_SIZE * 32 where PAGE_SIZE is usually 1KiB (see /usr/include/linux/a.out.h).Of course these values can be completely reconfigured. Moreover MAX_ARG_STRLEN is Linux specific and was introduced in Linux 2.6.23. For more information about what the limits actually are, please see What defines the maximum size for a command single argument?.UpdateOops, you can actually use the --file argument for this. It looks like you can do something like (without having tested):{  echo -n \  sed 's//\/' FILE  echo -n \} | dialog --yesno --file '&1' 10 100No need for the sed if you know there are no quotes in the file. Or alternatively just put everything you need in the file (quotes, --yesno and all) and simply do:dialog --file FILE