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

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



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.

Uncommenting line 3, does not fix the problem - same blanking output.

Commenting out line 5, and uncommenting one of line 4, 6 or 7, also
does not fix the problem.

In fact, 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.

With one of line 5 - line 7 uncommented, if I run from xterm:
test.sh|less
this also gives the expected output, but requires manual entry of
"|less" command, which is part of what I want to avoid of course.

(BTW, running test.sh inside a gnu screen session works 'as expected'.)

TIA
Zenaan


Reply to: