[DMC-883] gfal-ls fails when trying to evaluate the LS_COLORS envvar Created: 09/Sep/16  Updated: 06/Feb/17  Resolved: 12/Sep/16

Status: Closed
Project: DMC - Development
Component/s: None
Affects Version/s: gfal2-util 1.4
Fix Version/s: gfal2-util 1.5.0
Security Level: Public Data (This ticket is visible to anyone on the internet and will be indexed by search engines)

Type: Bug Priority: Minor
Reporter: Oliver Keeble Assignee: Alejandro Alvarez Ayllon
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Component Watchers:


From RQF0638850;

Hi all,

one of our users encountered a problem with gfal-ls, which failed when
trying to evaluate the LS_COLORS envvar [1].

Apparently the user had been sourcing a somewhat malformed file
coloring scheme [2]
~~> *.com has only been set to bold without any further coloring and
had not been separated from *.tar by a ':' – apparently, bash/zsh have
been skipping that without complaints.

Probably the fastest thing would be a "try: typ, color =
entry.split('=') except: pass" and drop the coloring if the env is broken?


Traceback (most recent call last):
File "/usr/bin/gfal-ls", line 24, in <module>
from gfal2_util.shell import Gfal2Shell
File "/usr/lib/python2.6/site-packages/gfal2_util/shell.py", line 25, in
import ls # @UnusedImport
File "/usr/lib/python2.6/site-packages/gfal2_util/ls.py", line 63, in
typ, color = entry.split('=')
ValueError: too many values to unpack


> gfal2_util/ls.py
color_dict = dict()
color_env = os.environ.get('LS_COLORS', None)
if color_env:
for entry in [entry for entry in color_env.split(':') if '=' in entry]:
typ, color = entry.split('=')
color_dict[typ] = color

Comment by Alejandro Alvarez Ayllon [ 12/Sep/16 ]

ls actually warns about the invalid value

# ls
ls: unparsable value for LS_COLORS environment variable

I'd say it would be nice for gfal2-util to do it too.

Comment by GitLab service [ 12/Sep/16 ]

Alejandro Alvarez Ayllon mentioned this issue in a commit of dmc/gfal2-util:
'DMC-883: Warning if LS_COLORS can't be parsed'

Comment by Clockwork Droid [ 12/Sep/16 ]

SUCCESS: Integrated in Jenkins build (devel) gfal2-util #47 (See https://jenkins.cern.ch/fts-dmc/job/(devel)%20gfal2-util/47/)
DMC-883: Warning if LS_COLORS can't be parsed (alejandro.alvarez.ayllon: rev 75c448dc9cdfd6f1b1b3b46a8182bb39692002a6)

Comment by GitLab service [ 06/Feb/17 ]

Alejandro Alvarez Ayllon mentioned this issue in a commit of dmc/gfal2-util:
'DMC-883: Warning if LS_COLORS can't be parsed'

Generated at Mon Aug 21 21:25:13 CEST 2017 using JIRA 7.3.8#73019-sha1:94e8771b8094eef96c119ec22b8e8868d286fa88.