Re: our containers with alias vim=vi

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

 



On 13/10/20 07:45 +0200, Zdenek Dohnal wrote:

On 10/12/20 5:15 PM, Joe Doss wrote:
On 10/12/20 1:50 AM, Zdenek Dohnal wrote:
This would break using Vim when vim-minimal and vim-enhanced are
installed (it would start Vi instead of typed Vim). To make it work,
vim-minimal would have to conflict with vim-enhanced, which doesn't make
sense - Vi and Vim binaries can exist together just fine.

I have vim-enhanced and vim-minimal installed

# rpm -qa |grep vim
vim-common-8.2.1770-1.fc33.x86_64
vim-filesystem-8.2.1770-1.fc33.noarch
vim-minimal-8.2.1770-1.fc33.x86_64
vim-enhanced-8.2.1770-1.fc33.x86_64

and when I type vi it launches vim.
I'm sorry I forgot about this alias - yes, there is an alias which is
applied when both - vim-minimal and vim-enhanced - are installed so it
launches 'vim' when you type 'vi'. I would say less people will complain
if something has more features than if it has less, so I'm content with
this alias.

# whereis vi
vi: /usr/bin/vi /usr/share/man/man1p/vi.1p.gz /usr/share/man/man1/vi.1.gz
# /usr/bin/vi --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 29 2020 00:00:00)

It doesn't look like these are existing together just fine. It seems
that vim takes over vi. Shouldn't these conflict and only one can be
installed over the other?
'Vi' as the original project is no longer (I'm not sure for how long)
shipped in Fedora. 'Vi' we ship is just 'VIM' compiled with 'small' set
of features (f.e. without syntax highlighting) to mimic the original
'Vi'. So if you run 'vi --version' it always shows 'VIM'.

In the end I find it incorrect to mislead users by default by telling
them 'Vim works' but Vi is run instead - Vi and Vim don't have the same
set of features, which may lead into bug reports caused by this mistake.

Isn't that the reverse behavior detailed above? I type vi on Fedora
Workstation it launches vim? I assume this isn't causing bug reports.
You're right, as I wrote above - aliasing vi->vim doesn't seem as a
problem to me, but aliasing vim->vi as clime suggested can cause mislead
for users.

I would also appreciate if "vim" ran the executable installed by
vim-minimal. I frequently type "vim" on servers I don't own and then
grumble that it fails and I have to run "vi" instead. It **is** vim,
it's just not installed with that name.  Insisting that users call it
vi when we know it's vim and they know it's vim seems unnecessary.

$ rpm -qf /usr/bin/vi
vim-minimal-8.2.1770-1.fc32.x86_64

Could vim-minimal and vim-enhanced both install the same
/etc/profile.d/vim.sh file that did something like this?

if [ -n "${BASH_VERSION-}" -o -n "${KSH_VERSION-}" -o -n "${ZSH_VERSION-}" ]; then
  [ "`/usr/bin/id -u 2>/dev/null || echo 0`" -le 200 ] && return
  # for bash and and ksh and zsh
  case "$(type -t vim)-$(type -t vi)" in
    file-file)
      # both vim and vi are present
      alias vi=vim
      alias view="vim -R"
      ;;
    -file)
      # only vim-minimal is installed, expose it as 'vim' too
      alias vim=vi
      ;;
  esac
fi

Thinking about it further, the existing aliasing of vi to /usr/bin/vim
is too greedy. It only checks whether there's an existing alias, which
means if I install some other binary as /usr/local/bin/vi (or another
location that is earlier in $PATH than /usr/bin and /bin) then it gets
overridden by the alias for 'vi'. If I have a shell function for 'vi'
it gets overridden by the alias for 'vi'. Who decided that's what I
want?

The script above could check that $(type vim)-$(type vi) is exactly
/usr/bin/vim-/usr/bin/vi so we don't mess with users' expectations
unless vim and vi are both hashed to the paths that we expect for
vim-enhanced and vim-minimal.
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux