momo-lab / xxenv-latest

This **env(pyenv, rbenv, nodenv, goenv, phpenv, luaenv) plugin replaces the version specified in the argument with the latest version.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uninstall: head: illegal option -- -

hugovk opened this issue · comments

on macOS Mojave, iTerm2, zsh 5.7.1:

$ which head
/usr/bin/head
$ pyenv latest uninstall 3.7
head: illegal option -- -
usage: head [-n lines | -c bytes] [file ...]

man head gives:

HEAD(1)                   BSD General Commands Manual                  HEAD(1)

NAME
     head -- display first lines of a file

SYNOPSIS
     head [-n count | -c bytes] [file ...]

DESCRIPTION
     This filter displays the first count lines or bytes of each of the specified files, or of the standard input if no files
     are specified.  If count is omitted it defaults to 10.

     If more than a single file is specified, each file is preceded by a header consisting of the string ``==> XXX <=='' where
     ``XXX'' is the name of the file.

EXIT STATUS
     The head utility exits 0 on success, and >0 if an error occurs.

SEE ALSO
     tail(1)

HISTORY
     The head command appeared in PWB UNIX.

BSD                              June 6, 1993                              BSD

I tried this:

-    for version in $(get_local_versions $version_prefix | head --lines=-1); do
+    for version in $(get_local_versions $version_prefix | head -n=-1); do

But it gave:

$ pyenv latest uninstall 3.7
head: illegal line count -- =1

What version of head was this written for, and what does --lines=-1 do?

Please try "head -n -1" command.
If successful, fix it.

$ git diff
diff --git a/bin/xxenv-latest b/bin/xxenv-latest
index 90bf61c..7c59143 100755
--- a/bin/xxenv-latest
+++ b/bin/xxenv-latest
@@ -130,7 +130,7 @@ uninstall_not_latest() {
         esac
         shift 1
     done
-    for version in $(get_local_versions $version_prefix | head --lines=-1); do
+    for version in $(get_local_versions $version_prefix | head -n -1); do
         $COMMAND uninstall $new_args $version
     done
 }
$ pyenv latest uninstall 3.7
head: illegal line count -- -1

@momo-lab @hugovk, PR #13 submitted to address this issue.

marged.