|
|
#1 |
|
Prospect
Join Date: Oct 2003
Posts: 18
|
The dir/ls command, more command, and color
Well, with the release of Panther, it ended up nuking a lot of my custom-done UNIX modifications in the /etc directory.
One of the more annoying replacements it did was to nuke the little alias I made for the dir command: dir -Al --color=always | more So when I went back into the Terminal to fix it up and add this to my list of aliases, I end up getting stuff like this: drwx------ 44 skywalk staff 1496 Nov 2 15:08 ESC[01;34mLibraryESC[0m drwxr-xr-x 18 skywalk staff 612 Sep 14 12:29 ESC[01;34mMP3sESC[0m drwx------ 2 skywalk staff 68 Jun 4 2002 ESC[01;34mMoviesESC[0m drwx------ 4 skywalk staff 136 Aug 30 14:56 ESC[01;34mMusicESC[0m drwx------ 5 skywalk staff 170 Sep 1 00:26 ESC[01;34mPicturesESC[0m However, if I don't pipe it through more, the colors end up coming out fine. What's wrong with more? It accepted color inputs in 10.2, why can't it do that now? As a sidenote, I *am* using the Fink GNU-Based version of fileutils (4.1)... if that says anything. And the 10.2 more *did* properly accept the GNU version of dir.
__________________
"The light at the end of the tunnel is the headlamp to an oncoming train." |
|
|
|
|
|
#2 |
|
All Star
Join Date: Jan 2002
Location: CO, USA
Posts: 908
|
Have you tried piping to less instead of more? less tends to be more capable.
|
|
|
|
|
|
#3 |
|
Major Leaguer
Join Date: Jan 2002
Location: Adelaide, South Australia
Posts: 470
|
I think you'll probably need just a little bit more than a pipe to less: you also need to let less know that the control sequences should be interpreted. Have a go with piping to "less -R", which just worked for me (using a custom display of files: "lc" for any old-timers still left in here).
Oh yeah, "more -R" seems to work fine as well. (Edit: well that ain't too surprising given that "more" is "less". cf the parallel thread in Unix General. Of course the behaviour of each may well depend on which way it's invoked, so that the traditional "moreish" things work etc etc) Cheers, Paul Last edited by pmccann; 11-04-2003 at 06:51 AM. |
|
|
|
|
|
#4 |
|
Triple-A Player
Join Date: Feb 2003
Location: back in t'ol' smoke :(
Posts: 225
|
not for me
Well that didnt seem to work for me. I still get non-colored output. any ideas?
I am running the panther retail build, and I ran 'more -V' which gave me... Code:
more -V less 378 Copyright (C) 2002 Mark Nudelman less comes with NO WARRANTY, to the extent permitted by law. For information about the terms of redistribution, see the file named README in the less distribution. Homepage: http://www.greenwoodsoftware.com/less
__________________
JKP. |
|
|
|
|
|
#5 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
$ which ls
/sw/bin/ls or /bin/ls what does /bin/ls -Gl | less -R get you? |
|
|
|
|
|
#6 |
|
Triple-A Player
Join Date: Feb 2003
Location: back in t'ol' smoke :(
Posts: 225
|
Sorted.
its OK merv.
I've just read the ls manual, and discovered that you can set a couple of environment variables that sorts it out. just add this to your .bashrc Code:
# correct the problem with ls and more export CLICOLOR=true export CLICOLOR_FORCE=true solved.
__________________
JKP. |
|
|
|
|
|
#7 |
|
Triple-A Player
Join Date: Feb 2003
Location: back in t'ol' smoke :(
Posts: 225
|
./configure is broken now...!
An interesting oddity has happened since I solved the problem using these environ variables:
If I try to run configure for some peice of software to generate a makefile, get the following output: Code:
checking whether build environment is sane... configure: error: ls -t appears to fail. Make sure there is not a broken alias in your environment configure: error: newly created file is older than distributed files! Check your system clock Is there another way I can solve the problem, or alternatively I thought one way around it would be to write a shell script that takes a command as an input , and would disable the envrions (set them to null), run the passed command, and then renable the variables? bit of a botch I know, but I cant see another way.... /edit: fold -mt
__________________
JKP. Last edited by mervTormel; 11-09-2003 at 05:44 PM. |
|
|
|
|
|
#8 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
ok here. investigate some more. and why conceal "some piece of software" from us? tell us what and let's compare realities.
Code:
$ set | grep COLOR CLICOLOR=1 CLICOLOR_FORCE=1 LSCOLORS=exfxcxdxbxegedabagacad darkstat-2.6 $ ./configure checking for a BSD-compatible install... /sw/bin/install -c checking whether build environment is sane... yes ... |
|
|
|
|
|
#9 |
|
Triple-A Player
Join Date: Feb 2003
Location: back in t'ol' smoke :(
Posts: 225
|
merv - its not 'some piece'...its every piece!
at least in the last few days, and disabling them always fixed it. odd. oh and: Code:
set | grep COLOR CLICOLOR=true CLICOLOR_FORCE=true
__________________
JKP. |
|
|
|
|
|
#10 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
ah.
well, do you alias ls? $ alias ls -bash: alias: ls: not found and the time error is cumulative from the sane/ls error, so solve the ls error and time issue should go away. from configure... Code:
echo "$as_me:$LINENO: checking whether build environment is sane" >&5
echo $ECHO_N "checking whether build environment is sane... $ECHO_C"
>&6
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$*" != "X $srcdir/configure conftest.file" \
&& test "$*" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
{ { echo "$as_me:$LINENO: error: ls -t appears to fail. Make
sure there is not a broken
alias in your environment" >&5
echo "$as_me: error: ls -t appears to fail. Make sure there is not a
broken
alias in your environment" >&2;}
{ (exit 1); exit 1; }; }
fi
test "$2" = conftest.file
)
then
# Ok.
:
else
{ { echo "$as_me:$LINENO: error: newly created file is older than
distributed files!
Check your system clock" >&5
echo "$as_me: error: newly created file is older than distributed
files!
Check your system clock" >&2;}
{ (exit 1); exit 1; }; }
fi
|
|
|
|
|
|
#11 |
|
Triple-A Player
Join Date: Feb 2003
Location: back in t'ol' smoke :(
Posts: 225
|
id got that far merv...i know its ls as i had a look at the configure code!
![]() the other answer is i dont alias ls...just add the environ variables. /me = puzzled!
__________________
JKP. |
|
|
|
|
|
#12 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
well, step thru the tests...
Code:
cd /path/to/configure touch conftest.file srcdir=. ls -Lt $srcdir/configure conftest.file ls -t $srcdir/configure conftest.file set X `ls -t $srcdir/configure conftest.file` echo "$*" oh, what is your term type? echo $TERM |
|
|
|
|
|
#13 |
|
Triple-A Player
Join Date: Feb 2003
Location: back in t'ol' smoke :(
Posts: 225
|
So ...
Code:
ls -Lt $srcdir/configure conftest.file conftest.file ./configure ls -t $srcdir/configure conftest.file conftest.file ./configure set X `ls -t $srcdir/configure conftest.file` echo "$*" X conftest.file ./configure
__________________
JKP. |
|
|
|
|
|
#14 |
|
MVP
Join Date: Jan 2002
Location: Brisbane, Australia
Posts: 1,108
|
What you need t do is to set your env vars for an interactive shell, but unset them for a non interactive shell, that way configure will get 'normal' ls output it wants and you will have pretty colors 8-)
Quick hacked up example.... Code:
$ export FOO=BAR
$ echo $FOO
BAR
$ cat xx
#! /bin/bash
echo $- "<-----"
X=`echo $- | grep i`
if [ "X$X" == "X" ]
then
echo no inter $X
unset FOO
else
echo interactive $X
export FOO=BAR
fi
echo "XXX $FOO XXX"
$ ./xx
hB <-----
no inter
XXX XXX
$ . ./xx
himBH <-----
interactive himBH
XXX BAR XXX
__________________
Douglas G. Stetner UNIX Live Free Or Die |
|
|
|
|
|
#15 |
|
Triple-A Player
Join Date: Feb 2003
Location: back in t'ol' smoke :(
Posts: 225
|
Well cheers Stener...
That was kinda like what I was thinking, but It still doesnt explain why merv can use exactly the same variables as me and not have a problem! worst comes to the worse and ill do that. Many thanks
__________________
JKP. |
|
|
|
|
|
#16 | |||||||||||||||||||
|
Prospect
Join Date: Oct 2003
Posts: 18
|
Re: Sorted.
I've tried shoving this in my /etc/bashrc file but I still get the same garbage as the stuff in the first post. The environmental variables are set when I do a set, but it doesn't seem to affect anything. I'll just stick with using the -R switch for now, but if anyone has a reason why as to setting these variables isn't doing anything then I'd like to know. ![]() Thanks a lot!
__________________
"The light at the end of the tunnel is the headlamp to an oncoming train." |
|||||||||||||||||||
|
|
|
|
|
#17 | |||||||||||||||||||
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
Re: Re: Sorted.
try: $ TERM=vt100 ls -l |
|||||||||||||||||||
|
|
|
![]() |
|
|