Uploaded image for project: 'DMC - Development'
  1. DMC - Development
  2. DMC-883

gfal-ls fails when trying to evaluate the LS_COLORS envvar

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: gfal2-util 1.4
    • Fix Version/s: gfal2-util 1.5.0
    • Component/s: None
    • Security Level: Public Data (This ticket is visible to anyone on the internet and will be indexed by search engines)
    • Labels:
      None

      Description

      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?

      Cheers,
      Thomas

      [1]
      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
      <module>
      import ls # @UnusedImport
      File "/usr/lib/python2.6/site-packages/gfal2_util/ls.py", line 63, in
      <module>
      typ, color = entry.split('=')
      ValueError: too many values to unpack

      [2]
      LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:.cmd=01;32:.exe=01;32:.com=01;.tar=01;33:.tgz=01;33:.arj=01;33:.taz=01;33:.lzh=01;33:.zip=01;33:.z=01;33:.Z=01;38:.gz=01;38:.deb=01;38:.jpg=01;38:.gif=01;38:.bmp=01;38:.ppm=01;38:.tga=01;38:.xbm=01;38:.xpm=01;38:.tif=01;38:.mpg=01;37:.avi=01;37:.gl=01;37:*.dl=01;37:

      [3]
      > 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

        Attachments

          Activity

            People

            • Assignee:
              aalvarez Alejandro Alvarez Ayllon
              Reporter:
              okeeble Oliver Keeble
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: