Bug 1683879 - cabal bash completion script should be moved
Summary: cabal bash completion script should be moved
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: cabal-install
Version: 29
Hardware: All
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Jens Petersen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-28 02:53 UTC by Chris King-Parra
Modified: 2019-03-23 02:56 UTC (History)
1 user (show)

Fixed In Version: cabal-install-2.0.0.1-11.fc29
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-03-23 02:56:16 UTC
Type: Bug


Attachments (Terms of Use)

Description Chris King-Parra 2019-02-28 02:53:45 UTC
Description of problem:

  The bash completion file for this package is installed as
'/etc/bash_completion.d/cabal'. According to the FHS, files 
under '/etc/' are for changes by the local administrator
only. It should be under '/usr/share' instead.

  I suggest the completion script should be installed as
'/usr/share/bash-completion/completions/cabal', to match
the convention used by the 'bash-completion' package. 
Many (most?) other packages also use this convention, 
like 'libvirt-bash-completion', for example.

Version-Release number of selected component (if applicable):
  Version:  2.0.0.1
  Release:  10.fc29

How reproducible:
  Always.

Steps to Reproduce:
1. Install cabal-install:    'dnf install cabal-install'
2. List the packages files:  'rpm -ql cabal-install | grep completion'

Actual results:
   '/etc/bash_completion.d/cabal'

Expected results:
   '/usr/share/bash-completion/completions/cabal'

Comment 1 Jens Petersen 2019-02-28 04:10:07 UTC
Thanks a lot for reporting this, Chris

Comment 2 Jens Petersen 2019-02-28 04:16:28 UTC
(Presumably /etc/profile.d/ is still acceptable?)

Fixing initially for F30/Rawhide and F29...

Comment 3 Chris King-Parra 2019-02-28 05:46:25 UTC
> Thanks a lot for reporting this, Chris

  No problemo. Thank you for maintaining all these Haskell
packages :^).

> (Presumably /etc/profile.d/ is still acceptable?)

  You mean the '/etc/profile.d/cabal-install.sh' file?
Didn't think of that until now. I think it makes sense to
keep it there, though, since It's more of a configuration
file than a script, and that's where most people will look
for things that change their shells environment (other 
than shell specific startup files).

  By the way, when looking at 'cabal-install.sh' I noticed
that a few parameter expansions are unquoted. Specifically
the $HOME variable. This will cause the script to break if
the path to a users home directory has a space in it. (For
example, if $HOME comes from a network share with windows-y
path names.)

  Simply quoting all the variables will fix this. I'll
submit a new bug report with better description and a
rewritten version of the 'cabal-install.sh' tomorrow
after I get some sleep.

  (It would be best if all shell scripts sent to the
Fedora package build system was automatically linted
by ShellCheck. Unquoted variables are an extremely
common and easy to fix syntax error.)

Comment 4 Fedora Update System 2019-02-28 06:19:58 UTC
cabal-install-2.0.0.1-11.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-18ada39c0c

Comment 5 Jens Petersen 2019-02-28 06:23:52 UTC
(In reply to Chris King-Parra from comment #3)
>   Simply quoting all the variables will fix this. I'll
> submit a new bug report with better description and a
> rewritten version of the 'cabal-install.sh' tomorrow
> after I get some sleep.

Thanks!  That would be good

>   (It would be best if all shell scripts sent to the
> Fedora package build system was automatically linted
> by ShellCheck. Unquoted variables are an extremely
> common and easy to fix syntax error.)

That's true.  Maybe some job could be added to taskotron say.

Comment 6 Fedora Update System 2019-03-01 03:35:52 UTC
cabal-install-2.0.0.1-11.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-18ada39c0c

Comment 7 Chris King-Parra 2019-03-02 05:12:40 UTC
> >   Simply quoting all the variables will fix this. I'll
> > submit a new bug report with better description and a
> > rewritten version of the 'cabal-install.sh' tomorrow
> > after I get some sleep.
>
> Thanks!  That would be good

  Turns out that the script works as intended. That
is because unquoted variables don't undergo word
splitting in assignment statements. It's just unsafe
to leave them unquoted in any other circumstance (eg
as arguments to commands, etc.) Since it doesn't 
break anything, I didn't file a bug report.

 Here's an edited version, just in case you feel
like updating it to encourage the use of quotes by
local admins if they make changes.

#!/bin/sh
# add ~/.cabal/bin to the users PATH is it exists
CABALBIN="${HOME}/.cabal/bin"
if ! echo "${PATH}" | /bin/grep -q "${CABALBIN}" ; then
    if [ -d "${CABALBIN}" ]; then
        PATH="${PATH}:${CABALBIN}"
        export PATH
    fi
fi

Comment 8 Jens Petersen 2019-03-02 10:48:20 UTC
Thanks, Chris, for the attention to detail.

Your changes should be in https://src.fedoraproject.org/rpms/cabal-install/c/362f69476a397a077e80877a3d1a189ba55577f3?branch=master cheers!

Comment 9 Fedora Update System 2019-03-23 02:56:16 UTC
cabal-install-2.0.0.1-11.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.