├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── lib └── .keep ├── profile ├── screenshot.gif ├── src └── .keep ├── test ├── bash-support │ ├── build_test.sh │ ├── fetch_test.sh │ └── list_test.sh ├── fetch │ ├── commandline_paramter_test.sh │ └── fetch_test.sh ├── help │ └── help_test.sh ├── install │ ├── commandline_paramter_test.sh │ └── install_test.sh ├── list │ ├── commandline_paramter_test.sh │ ├── list_local_test.sh │ ├── list_remote_test.sh │ └── list_support_test.sh ├── main │ ├── commoandline_parameter_test.sh │ └── definition_test.sh ├── test_helper.sh ├── uninstall │ ├── commandline_paramter_test.sh │ └── uninstall_test.sh └── use │ ├── commandline_paramter_test.sh │ └── use_test.sh └── usr ├── bash-support ├── build ├── fetch └── list ├── fish-support ├── build ├── fetch └── list ├── shvm-fetch ├── shvm-help ├── shvm-install ├── shvm-list ├── shvm-uninstall ├── shvm-use ├── tcsh-support ├── build ├── fetch └── list └── zsh-support ├── build ├── fetch └── list /.gitignore: -------------------------------------------------------------------------------- 1 | /lib/* 2 | !/lib/.keep 3 | /src/* 4 | !/src/.keep 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | addons: 3 | apt: 4 | sources: 5 | - debian-sid 6 | packages: 7 | - shellcheck 8 | language: bash 9 | before_install: 10 | - mkdir $HOME/bin 11 | - curl -o $HOME/bin/bashtub https://raw.githubusercontent.com/ueokande/bashtub/master/bin/bashtub 12 | - chmod +x $HOME/bin/bashtub 13 | - export PATH="$HOME/bin:$PATH" 14 | script: 15 | - git ls-files usr/ profile | xargs shellcheck 16 | - bashtub `find test -name '*_test.sh'` 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Shin'ya Ueoka 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | shvm - A Version Manager for Shells 2 | =================================== 3 | 4 | ![shvm](screenshot.gif) 5 | 6 | Shvm is a command-line tool to easily install and manage multiple shell 7 | versions in your local environment. 8 | 9 | Requirements 10 | ------------ 11 | 12 | - A POSIX-compliant shells (i.e. dash, bash, or zsh) 13 | 14 | Installation 15 | ------------ 16 | 17 | Clone a shvm to a directory `$HOME/.shvm` via [GitHub](https://github.com/ueokande/shvm): 18 | 19 | ```sh 20 | git clone https://github.com/ueokande/shvm $HOME/.bashvm 21 | ``` 22 | 23 | and then, add the following code into your `.bash_profile`, `.zprofile`, or `.profile`: 24 | 25 | ```sh 26 | [ -r $HOME/.shvm/profile ] && . $HOME/.shvm/profile 27 | ``` 28 | 29 | Usage 30 | ----- 31 | 32 | ### Basic usage 33 | 34 | The below is an example, to install and use a certain shell version. 35 | 36 | ```sh 37 | # List installable bash versions on remote repository 38 | shvm list remote bash 39 | 40 | # Install a certain shell 41 | shvm install bash-2.0 42 | 43 | # Set a $PATH to current shell to use the installed shell 44 | shvm use bash-3.0 45 | 46 | # List installed shells in a local disk 47 | shvm list local 48 | 49 | # Launch it 50 | bash --version 51 | ``` 52 | 53 | ### Use various shell versions 54 | 55 | You can see another supported shells and use it like this: 56 | 57 | ```sh 58 | # List supported shells 59 | shvm list support 60 | 61 | # List installable fish versions 62 | shvm list remote fish 63 | 64 | # Install and use fish-2.0.0 65 | shvm use --install fish-2.0.0 66 | 67 | # List installed shells in a local disk 68 | shvm list local 69 | 70 | # Launch it 71 | fish --version 72 | ``` 73 | 74 | ### More informations 75 | 76 | Use `help` to display the helps of shvm: 77 | 78 | ``` 79 | shvm help 80 | ``` 81 | 82 | Licence 83 | ------- 84 | 85 | MIT 86 | -------------------------------------------------------------------------------- /lib/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ueokande/shvm/adcf5e0e3450f919b54e339176593b77948a832b/lib/.keep -------------------------------------------------------------------------------- /profile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | shvm_use() { 4 | install= 5 | target= 6 | 7 | while test $# != 0; do 8 | case "$1" in 9 | --help) 10 | "$SHVM_HOME/usr/shvm-use" --help 11 | return 0 12 | ;; 13 | --install) 14 | install=t 15 | ;; 16 | -*|--*) 17 | echo "Unrecognized option: $1" >&2 18 | return 1 19 | ;; 20 | *) 21 | target="$1" 22 | ;; 23 | esac 24 | shift 25 | done 26 | 27 | if [ -z "$target" ]; then 28 | "$SHVM_HOME/usr/shvm-use" --help 29 | return 1 30 | fi 31 | 32 | [ -n "$install" ] && "$SHVM_HOME/usr/shvm-install" "$target" 33 | 34 | if ! [ -d "$SHVM_HOME/lib/$target" ]; then 35 | echo "Unknown shell version: $target." >&2 36 | return 1 37 | fi 38 | 39 | export PATH="$SHVM_HOME/lib/$target/bin:$PATH" 40 | 41 | echo "Switched to $target" 42 | } 43 | export -f shvm_use 44 | 45 | shvm() { 46 | case "$1" in 47 | list) 48 | shift 49 | "$SHVM_HOME/usr/shvm-list" "$@" 50 | ;; 51 | use) 52 | shift 53 | shvm_use "$@" 54 | ;; 55 | fetch) 56 | shift 57 | "$SHVM_HOME/usr/shvm-fetch" "$@" 58 | ;; 59 | install) 60 | shift 61 | "$SHVM_HOME/usr/shvm-install" "$@" 62 | ;; 63 | uninstall) 64 | shift 65 | "$SHVM_HOME/usr/shvm-uninstall" "$@" 66 | ;; 67 | help) 68 | shift 69 | "$SHVM_HOME/usr/shvm-help" "$@" 70 | ;; 71 | --help) 72 | shift 73 | "$SHVM_HOME/usr/shvm-help" 74 | ;; 75 | --version) 76 | shift 77 | echo "shvm version 0.0.0" 78 | ;; 79 | -*|--*) 80 | echo "Unrecognized option: $1" >&2 81 | return 1 82 | ;; 83 | *) 84 | echo "Unrecognized command: $1" >&2 85 | return 1 86 | ;; 87 | esac 88 | } 89 | export -f shvm 90 | 91 | export SHVM_HOME=${SHVM_HOME:-$HOME/.shvm} 92 | -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ueokande/shvm/adcf5e0e3450f919b54e339176593b77948a832b/screenshot.gif -------------------------------------------------------------------------------- /src/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ueokande/shvm/adcf5e0e3450f919b54e339176593b77948a832b/src/.keep -------------------------------------------------------------------------------- /test/bash-support/build_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_build() { 4 | subject shvm install bash-4.0 5 | assert_true test -d "$SHVM_HOME/lib/bash-4.0" 6 | assert_equal 0 $status 7 | } 8 | -------------------------------------------------------------------------------- /test/bash-support/fetch_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_fetch_valid_version() { 4 | subject shvm fetch bash-3.2 5 | assert_true test -d "$SHVM_HOME/src/bash-3.2" 6 | } 7 | 8 | -------------------------------------------------------------------------------- /test/bash-support/list_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_list_bash_support() { 4 | subject shvm list remote bash 5 | assert_match '3.2' "$stdout" 6 | assert_match '4.2' "$stdout" 7 | } 8 | -------------------------------------------------------------------------------- /test/fetch/commandline_paramter_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_help() { 4 | subject shvm fetch --help 5 | assert_match 'Usage' "$stdout" 6 | assert_equal 0 $status 7 | } 8 | 9 | testcase_unrecognized_option() { 10 | subject shvm fetch --sushi 11 | assert_match 'Unrecognized option' "$stderr" 12 | assert_equal 1 $status 13 | } 14 | -------------------------------------------------------------------------------- /test/fetch/fetch_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_fetch_invalid_version() { 4 | assert_false shvm fetch su.shi 5 | } 6 | 7 | testcase_exit_when_source_already_exist() { 8 | subject shvm fetch bash-X.0 9 | assert_match 'already exists' "$stdout" 10 | } 11 | 12 | testcase_fetch_force() { 13 | mkdir -p $SHVM_HOME/src/bash-4.0 14 | subject shvm fetch --force bash-4.0 15 | assert_true test -f "$SHVM_HOME/src/bash-4.0/configure" 16 | } 17 | -------------------------------------------------------------------------------- /test/help/help_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_show_default_help_by_command() { 4 | subject shvm help 5 | assert_match 'sub-commands' "$stdout" 6 | assert_equal 0 $status 7 | } 8 | 9 | testcase_show_default_help_by_option() { 10 | subject shvm --help 11 | assert_match 'sub-commands' "$stdout" 12 | assert_equal 0 $status 13 | } 14 | 15 | testcase_show_help_of_command() { 16 | subject shvm help install 17 | assert_match 'shvm install' "$stdout" 18 | assert_equal 0 $status 19 | } 20 | 21 | testcase_show_help_of_help() { 22 | subject shvm help help 23 | assert_match 'shvm help' "$stdout" 24 | assert_equal 0 $status 25 | } 26 | 27 | testcase_show_help_of_help_by_option() { 28 | subject shvm help --help 29 | assert_match 'shvm help' "$stdout" 30 | assert_equal 0 $status 31 | } 32 | 33 | testcase_show_default_help_with_invalid_command() { 34 | subject shvm help sushi 35 | assert_match 'sub-commands' "$stdout" 36 | assert_equal 1 $status 37 | } 38 | 39 | testcase_unrecognized_option() { 40 | subject shvm help --sushi 41 | assert_match 'Unrecognized option' "$stderr" 42 | assert_equal 1 $status 43 | } 44 | -------------------------------------------------------------------------------- /test/install/commandline_paramter_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_help() { 4 | subject shvm install --help 5 | assert_match 'Usage' "$stdout" 6 | assert_equal 0 $status 7 | } 8 | 9 | testcase_unrecognized_option() { 10 | subject shvm install --sushi 11 | assert_match 'Unrecognized option' "$stderr" 12 | assert_equal 1 $status 13 | } 14 | -------------------------------------------------------------------------------- /test/install/install_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_failed_to_install() { 4 | subject shvm install su.shi 5 | assert_equal 1 $status 6 | } 7 | -------------------------------------------------------------------------------- /test/list/commandline_paramter_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_help() { 4 | subject shvm list --help 5 | assert_match 'Usage' "$stdout" 6 | assert_equal 0 $status 7 | } 8 | 9 | testcase_unrecognized_option() { 10 | subject shvm list --sushi 11 | assert_match 'Unrecognized option' "$stderr" 12 | assert_equal 1 $status 13 | } 14 | 15 | testcase_unrecognized_option() { 16 | subject shvm list sushi 17 | assert_match 'Unrecognized command' "$stderr" 18 | assert_equal 1 $status 19 | } 20 | 21 | testcase_unrecognized_option() { 22 | subject shvm list sushi 23 | assert_match 'Unrecognized command' "$stderr" 24 | assert_equal 1 $status 25 | } 26 | -------------------------------------------------------------------------------- /test/list/list_local_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_show_list_in_local() { 4 | subject shvm list local 5 | assert_match 'X.0' "$stdout" 6 | assert_match 'X.1' "$stdout" 7 | assert_match 'Y.0' "$stdout" 8 | } 9 | 10 | testcase_show_curren_bash() { 11 | PATH="$SHVM_HOME/lib/bash-X.1/bin:$PATH" subject shvm list local 12 | assert_match '\* bash-X.1' "$stdout" 13 | } 14 | -------------------------------------------------------------------------------- /test/list/list_remote_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_show_help_when_no_targets() { 4 | subject shvm list remote 5 | assert_match 'Usage' "$stdout" 6 | } 7 | -------------------------------------------------------------------------------- /test/list/list_support_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_show_supported_shells() { 4 | mkdir $SHVM_HOME/usr/{wsh,xsh,ysh}-support 5 | subject shvm list support 6 | assert_match 'xsh' "$stdout" 7 | assert_match 'ysh' "$stdout" 8 | assert_match 'zsh' "$stdout" 9 | rmdir $SHVM_HOME/usr/{wsh,xsh,ysh}-support 10 | } 11 | -------------------------------------------------------------------------------- /test/main/commoandline_parameter_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_help_command() { 4 | subject shvm help 5 | assert_match "Usage" "$stdout" 6 | assert_equal 0 $status 7 | } 8 | 9 | testcase_help_option() { 10 | subject shvm --help 11 | assert_match "Usage" "$stdout" 12 | assert_equal 0 $status 13 | } 14 | 15 | testcase_version_option() { 16 | subject shvm --version 17 | assert_match "version" "$stdout" 18 | assert_equal 0 $status 19 | } 20 | 21 | testcase_unrecognized_option() { 22 | subject shvm --sushi 23 | assert_match "Unrecognized option" "$stderr" 24 | assert_match "--sushi" "$stderr" 25 | assert_equal 1 $status 26 | } 27 | 28 | testcase_unrecognized_command() { 29 | subject shvm sushi 30 | assert_match "Unrecognized command" "$stderr" 31 | assert_match "sushi" "$stderr" 32 | assert_equal 1 $status 33 | } 34 | -------------------------------------------------------------------------------- /test/main/definition_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_shvm_is_function() { 4 | subject type -t shvm 5 | assert_match 'function' "$stdout" 6 | } 7 | -------------------------------------------------------------------------------- /test/test_helper.sh: -------------------------------------------------------------------------------- 1 | 2 | before_each() { 3 | tmpdir=$(mktemp -d) 4 | export SHVM_HOME=$tmpdir 5 | 6 | mkdir -p $SHVM_HOME/lib/bash-{X.0,X.1,Y.0} 7 | mkdir -p $SHVM_HOME/src/bash-X.0 8 | ln -s $(readlink -f $(dirname $BASH_SOURCE)/../bin) $SHVM_HOME/bin 9 | cp -r $(readlink -f $(dirname $BASH_SOURCE)/../usr) $SHVM_HOME/usr 10 | cp $(readlink -f $(dirname $BASH_SOURCE)/../profile) $SHVM_HOME/profile 11 | local current_bash_path=$(which bash) 12 | for dir in $SHVM_HOME/lib/bash-*; do 13 | mkdir ${dir}/bin 14 | ln -s $current_bash_path ${dir}/bin/bash 15 | done 16 | 17 | source ${SHVM_HOME}/profile 18 | } 19 | 20 | after_each() { 21 | rm -rf $tmpdir 22 | } 23 | -------------------------------------------------------------------------------- /test/uninstall/commandline_paramter_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_help() { 4 | subject shvm uninstall --help 5 | assert_match 'Usage' "$stdout" 6 | assert_equal 0 $status 7 | } 8 | 9 | testcase_unrecognized_option() { 10 | subject shvm uninstall --sushi 11 | assert_match 'Unrecognized option' "$stderr" 12 | assert_equal 1 $status 13 | } 14 | -------------------------------------------------------------------------------- /test/uninstall/uninstall_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_uninstall_installed_version() { 4 | mkdir $SHVM_HOME/lib/bash-X.Y 5 | subject shvm uninstall bash-X.Y 6 | assert_false test -d "$SHVM_HOME/lib/bash-X.Y" 7 | } 8 | 9 | testcase_uninstall_gone_version() { 10 | subject shvm uninstall su.shi 11 | assert_match "gone" "$stdout" 12 | assert_equal 1 $status 13 | } 14 | -------------------------------------------------------------------------------- /test/use/commandline_paramter_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_help() { 4 | subject shvm use --help 5 | assert_match 'Usage' "$stdout" 6 | assert_equal 0 $status 7 | } 8 | 9 | testcase_unrecognized_option() { 10 | subject shvm use --sushi 11 | assert_match 'Unrecognized option' "$stderr" 12 | assert_equal 1 $status 13 | } 14 | -------------------------------------------------------------------------------- /test/use/use_test.sh: -------------------------------------------------------------------------------- 1 | source $(dirname $BASH_SOURCE)/../test_helper.sh 2 | 3 | testcase_use_temporary() { 4 | shvm use bash-X.0 >/dev/null 5 | 6 | assert_match 'bash-X.0' "$PATH" 7 | assert_match 'bash-X.0' "$(which bash)" 8 | } 9 | 10 | testcase_use_invalid_version() { 11 | assert_false shvm use su.shi 12 | } 13 | 14 | testcase_use_with_install() { 15 | shvm use bash-3.2 --install >/dev/null 2>&1 16 | assert_match 'bash-3.2' "$(which bash)" 17 | } 18 | -------------------------------------------------------------------------------- /usr/bash-support/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | [ -z "$1" ] && exit 1 5 | 6 | abort() { 7 | echo "$@" >&2 8 | exit 1 9 | } 10 | 11 | builddir=$(mktemp -d) 12 | ( cd "$builddir" 13 | 14 | echo "Checking build system..." 15 | "$SHVM_HOME/src/$1/configure" \ 16 | --prefix="$SHVM_HOME/lib/$1" 2>/dev/tty >/dev/null \ 17 | || abort "Failed to configure $1}. 18 | Make sure that '$SHVM_HOME/src/$1--prefix=$SHVM_HOME/lib/$1' \ 19 | succeeds before install" 20 | 21 | echo "Building ${1}..." 22 | make -C "$builddir" install >/dev/null 2>&1 \ 23 | || abort "Failed to build ${1}. 24 | Make sure that 'make -C $builddir install' succeeds before install" 25 | ) 26 | 27 | rm -rf "$builddir" 28 | -------------------------------------------------------------------------------- /usr/bash-support/fetch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | [ -z "$1" ] && exit 1 5 | 6 | curl -SL# "ftp://ftp.gnu.org/gnu/bash/${1}.tar.gz" |\ 7 | tar zxf - -C "$SHVM_HOME/src" 8 | -------------------------------------------------------------------------------- /usr/bash-support/list: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | curl -sSl 'ftp://ftp.gnu.org/gnu/bash/' |\ 5 | grep '^bash-.*.tar.gz$' |\ 6 | grep -v -- '-doc-' |\ 7 | while read -r line; do 8 | echo "${line%.tar.gz}" 9 | done 10 | -------------------------------------------------------------------------------- /usr/fish-support/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | [ -z "$1" ] && exit 1 5 | 6 | abort() { 7 | echo "$@" >&2 8 | exit 1 9 | } 10 | 11 | ( 12 | cd "$SHVM_HOME/src/$1" 13 | 14 | echo "Checking build system..." 15 | 16 | autoconf 17 | ./configure --prefix="$SHVM_HOME/lib/$1" 2>/dev/tty >/dev/null ||\ 18 | abort "Failed to configure $1}. 19 | Make sure that 'cd \$SHVM_HOME/src/$1; ./configure --prefix=$SHVM_HOME/lib/$1' \ 20 | succeeds before install" 21 | 22 | echo "Building ${1}..." 23 | make install >/dev/null 2>&1 ||\ 24 | abort "Failed to build ${1}. 25 | Make sure that 'cd \$SHVM_HOME/src/$1; make install' succeeds before install" 26 | ) 27 | -------------------------------------------------------------------------------- /usr/fish-support/fetch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | [ -z "$1" ] && exit 1 5 | 6 | rm -rf "$SHVM_HOME/src/$1" 7 | 8 | git clone --branch "${1#fish-}" --depth 1 https://github.com/fish-shell/fish-shell "$SHVM_HOME/src/$1" 9 | -------------------------------------------------------------------------------- /usr/fish-support/list: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | git ls-remote --tags https://github.com/fish-shell/fish-shell |\ 5 | grep -F '^{}' |\ 6 | cut -d'/' -f3 |\ 7 | cut -d'^' -f1 |\ 8 | while read -r line; do 9 | echo "fish-$line" 10 | done 11 | -------------------------------------------------------------------------------- /usr/shvm-fetch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | help() { 5 | echo "Usage: shvm fetch " 6 | } 7 | 8 | force= 9 | target= 10 | 11 | while test $# != 0; do 12 | case "$1" in 13 | --help) 14 | help 15 | exit 0 16 | ;; 17 | -f|--force) 18 | force=t 19 | ;; 20 | -*|--*) 21 | echo >&2 "Unrecognized option: $1" 22 | exit 1 23 | ;; 24 | *) 25 | target="$1" 26 | ;; 27 | esac 28 | shift 29 | done 30 | 31 | IFS='-' read -r target_type target_version<" 6 | } 7 | 8 | target= 9 | 10 | while test $# != 0; do 11 | case "$1" in 12 | --help) 13 | help 14 | exit 0 15 | ;; 16 | -*|--*) 17 | echo >&2 "Unrecognized option: $1" 18 | exit 1 19 | ;; 20 | *) 21 | target="$1" 22 | ;; 23 | esac 24 | shift 25 | done 26 | 27 | if [ -x "$SHVM_HOME/usr/shvm-$target" ]; then 28 | "$SHVM_HOME/usr/shvm-$target" --help 29 | elif (hash "shvm-${target}" 2>/dev/null) then 30 | "shvm-${target}" --help 31 | else 32 | cat < [] 35 | 36 | The sub-commands for shvm: 37 | 38 | list Show currently available shells 39 | use Setup current shell to use a specific shell versions 40 | fetch Fetch source of a shell version 41 | install Install a shell version 42 | uninstall Uninstall a shell version 43 | help Display helps 44 | EOF 45 | 46 | [ -z "$target" ] || exit 1 47 | fi 48 | -------------------------------------------------------------------------------- /usr/shvm-install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | help() { 5 | echo "Usage: shvm install " 6 | } 7 | 8 | target= 9 | 10 | while test $# != 0; do 11 | case "$1" in 12 | --help) 13 | help 14 | exit 0 15 | ;; 16 | -*|--*) 17 | echo >&2 "Unrecognized option: $1" 18 | exit 1 19 | ;; 20 | *) 21 | target="$1" 22 | ;; 23 | esac 24 | shift 25 | done 26 | 27 | IFS='-' read -r target_type target_version< 58 | or: shvm support 59 | 60 | Avairable commands for shvm list 61 | 62 | local Show installed shell list in local (default) 63 | remote Show shell versions of the target able to install 64 | support Show supported shell types 65 | EOF 66 | } 67 | 68 | if [ $# -eq 0 ]; then 69 | local_list 70 | exit 0 71 | fi 72 | 73 | case "$1" in 74 | remote) 75 | shift 76 | remote_list "$1" 77 | ;; 78 | local) 79 | local_list 80 | ;; 81 | support) 82 | support_list 83 | ;; 84 | --help) 85 | shift 86 | help 87 | ;; 88 | -*|--*) 89 | echo >&2 "Unrecognized option: $1" 90 | exit 1 91 | ;; 92 | *) 93 | echo >&2 "Unrecognized command: $1" 94 | exit 1 95 | ;; 96 | esac 97 | -------------------------------------------------------------------------------- /usr/shvm-uninstall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | help() { 5 | echo "Usage: shvm uninstall " 6 | } 7 | 8 | target= 9 | 10 | while test $# != 0; do 11 | case "$1" in 12 | --help) 13 | help 14 | exit 0 15 | ;; 16 | -*|--*) 17 | echo >&2 "Unrecognized option: $1" 18 | exit 1 19 | ;; 20 | *) 21 | target="$1" 22 | ;; 23 | esac 24 | shift 25 | done 26 | 27 | if [ -z "$target" ]; then 28 | help 29 | exit 1 30 | fi 31 | 32 | if ! [ -d "$SHVM_HOME/lib/$target" ]; then 33 | echo "$target : already gone" 34 | return 1 35 | fi 36 | 37 | echo "$target : removing.." 38 | rm -rf "${SHVM_HOME:?}/lib/$target" 39 | -------------------------------------------------------------------------------- /usr/shvm-use: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | help() { 5 | cat < 7 | 8 | --install install the version if it is not in the local 9 | EOF 10 | } 11 | 12 | while test $# != 0; do 13 | case "$1" in 14 | --help) 15 | help 16 | exit 0 17 | ;; 18 | esac 19 | shift 20 | done 21 | -------------------------------------------------------------------------------- /usr/tcsh-support/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | [ -z "$1" ] && exit 1 5 | 6 | abort() { 7 | echo "$@" >&2 8 | exit 1 9 | } 10 | 11 | builddir=$(mktemp -d) 12 | ( cd "$builddir" 13 | 14 | echo "Checking build system..." 15 | "$SHVM_HOME/src/$1/configure" \ 16 | --prefix="$SHVM_HOME/lib/$1" 2>/dev/tty >/dev/null \ 17 | || abort "Failed to configure $1}. 18 | Make sure that '$SHVM_HOME/src/$1/configure --prefix=$SHVM_HOME/lib/$1' \ 19 | succeeds before install" 20 | 21 | echo "Building ${1}..." 22 | make -C "$builddir" install >/dev/null 2>&1 \ 23 | || abort "Failed to build ${1}. 24 | Make sure that 'make -C $builddir install' succeeds before install" 25 | ) 26 | 27 | rm -rf "$builddir" 28 | -------------------------------------------------------------------------------- /usr/tcsh-support/fetch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | [ -z "$1" ] && exit 1 5 | 6 | (curl 2>/dev/null -SL# "ftp://ftp.astron.com/pub/tcsh/old/${1}.tar.gz" ||\ 7 | curl -SL# "ftp://ftp.astron.com/pub/tcsh/${1}.tar.gz") |\ 8 | tar zxf - -C "$SHVM_HOME/src" 9 | -------------------------------------------------------------------------------- /usr/tcsh-support/list: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | curl -sSlL 'ftp://ftp.astron.com/pub/tcsh/old/' 'ftp://ftp.astron.com/pub/tcsh/' |\ 5 | grep '^tcsh-.*.tar.gz$' |\ 6 | grep -v 'exe\|bin\|win32src' |\ 7 | while read -r line; do 8 | echo "${line%.tar.gz}" 9 | done 10 | -------------------------------------------------------------------------------- /usr/zsh-support/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | [ -z "$1" ] && exit 1 5 | 6 | abort() { 7 | echo "$@" >&2 8 | exit 1 9 | } 10 | 11 | builddir=$(mktemp -d) 12 | ( cd "$builddir" 13 | 14 | echo "Checking build system..." 15 | "$SHVM_HOME/src/$1/configure" \ 16 | --prefix="$SHVM_HOME/lib/$1" 2>/dev/tty >/dev/null \ 17 | || abort "Failed to configure $1}. 18 | Make sure that '$SHVM_HOME/src/$1/configure --prefix=$SHVM_HOME/lib/$1' \ 19 | succeeds before install" 20 | 21 | echo "Building ${1}..." 22 | make -C "$builddir" install >/dev/null 2>&1 \ 23 | || abort "Failed to build ${1}. 24 | Make sure that 'make -C $builddir install' succeeds before install" 25 | ) 26 | 27 | rm -rf "$builddir" 28 | -------------------------------------------------------------------------------- /usr/zsh-support/fetch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | [ -z "$1" ] && exit 1 5 | 6 | (curl 2>/dev/null -SL# "ftp://ftp.zsh.org/zsh/old/${1}.tar.gz" ||\ 7 | curl -SL# "ftp://ftp.zsh.org/zsh/${1}.tar.gz") |\ 8 | tar zxf - -C "$SHVM_HOME/src" 9 | -------------------------------------------------------------------------------- /usr/zsh-support/list: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | curl -sSlL 'ftp://ftp.zsh.org/zsh/old/' 'ftp://ftp.zsh.org/zsh/' |\ 5 | grep '^zsh-.*.tar.gz$' |\ 6 | grep -v -- '-doc' |\ 7 | while read -r line; do 8 | echo "${line%.tar.gz}" 9 | done 10 | --------------------------------------------------------------------------------