[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: using less in a bash script, screen blanking, alternate screen



On 9/8/13, Zenaan Harkness <zen@freedbms.net> wrote:
> OK, I have the following script (reduced, just enough to demonstrate
> the problem):
>
> --- test.sh ---
> #!/bin/bash
> cmd="apt-cache search debian-installer | sort | egrep --color=always
> -i debian-installer"
> #tput nrrmc # line 3
> #less -REf <($cmd) # line 4
> less -REf <(bash -c "$cmd") # line 5
> #less -REf <(tput nrrmc; bash -c "$cmd") # line 6
> #less -REf <(bash -c "tput nrrmc; $cmd") # line 7
> ---
>
> I am running this script in a plan xterm (no embedded screen session),
> bash shell.
>
> When I manually run lines 2 then 5 in xterm, I get expected output in
> my terminal.
>
> When I run test.sh from xterm, I get a blank screen, followed by
> return to the xterm, as though the script didn't do anything! I would
> like to understand why.

Solution is use -X (--no-init) option to less.

> Commenting out line 5, and

> ... uncommenting line 4 gives an error, since the command is
> being substituted as though it is a single command, instead of a
> pipeline. I am wondering how I might fix this particular problem
> without using a full bash instantiation as seen in line 5 - line 7.

I am still interested in whether there is some command-substitution
alternative in bash, which can properly interpret pipe ("|")
character, to save the launching of a full sub-shell...

TIA
Zenaan


Reply to: