Coder Social home page Coder Social logo

bashvm's Introduction

BashVM - Bash Version Manager

BashVM is a command-line tool to easily install and manage multiple bash versions in your local environment.

Requirements

  • Bash 3.2+
  • Linux

Install

Clone current project from GitHub to $HOME/.bashvm,

git clone https://github.com/ueokande/bashvm $HOME/.bashvm

and add the following code,

source $HOME/.bashvm/bin/bashvm-init

into your .bash_profile

Usage

Lists bash versions

list sub-command with local option lists installed versions in your local:

bashvm list local

and with remote option lists available versions to install:

bashvm list remote

Uses a bash version

use sub-command switches current bash version to version X.Y:

bashvm use X.Y

The use sub-command available for in current shell. To switch default version, use --default option:

bashvm use X.Y --default

system target allows to use version installed in system (i.e. bash in /bin or /usr/bin):

bashvm use system

If specified version is not installed in local but an available version to install, use sub-command with --install installs and switches to the version.

bashvm use X.Y --install

Installs a bash version

Use install sub-command

bashvm install X.Y

More informations

Use help to display the helps of bashvm:

bashvm help

Use in Travis-CI

The below example is to use bashvm in Travis-CI.

sudo: false
cache:
  directories:
  - .bashvm/usr
env:
- RUN_BASH_VERSION=3.1
- RUN_BASH_VERSION=3.2
- RUN_BASH_VERSION=4.0
- RUN_BASH_VERSION=4.1
- RUN_BASH_VERSION=4.2
- RUN_BASH_VERSION=4.3
install:
- mkdir -p .bashvm
- curl  https://codeload.github.com/ueokande/bashvm/tar.gz/master | tar zx
- cp -r bashvm-master/* .bashvm/
before_script:
- export BASHVM_HOME=$(readlink -f  .bashvm)
- source .bashvm/bin/bashvm-init
- bashvm use --install $RUN_BASH_VERSION
script:
- bash your_test_script.sh

This examples use container-based infrastructure to enable caching directories in order to reduce build time of bash versions. In this example, $TRAVIS_BUILD_DIR/.bashvm/usr directory which contains built bash versions is cached. In install step, the archive of bashvm is downloaded by curl instead of git-clone. These commands allow to fetch the sources successfully under caching directories.

The build script run for each RUN_BASH_VERSION versions. The bash version is installed and switched in before_script, and the switched version is enabled on script.

Licence

MIT

bashvm's People

Contributors

ueokande avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bashvm's Issues

curl: (78) RETR response: 550

It works fine locally, but an error occurs when running it from GitHub Actions:

$ git clone https://github.com/ueokande/bashvm $HOME/.bashvm
$ source $HOME/.bashvm/bin/bashvm-init
$ bashvm use --install 5
Fetching bash-5...
#=#=#                                                                         
##O#- #                                                                       
##O=#  #                                                                      
#=#=-#  #                                                                     
-#O#- #   #                                                                   
curl: (78) RETR response: 550

Perils of `rm -fr $builddir`

Thanks for this. I was recently lamenting the lack of anything like this tool.

rm -rf $builddir

This is dangerous.

  1. Since $builddir isn't quoted, chaos will ensue if this ever becomes subject to word splitting for any reason. C.f.: bumblebeee
  2. since you don't have set -u, who knows what will happen if the variable is unset when we get to this point? C.f.: steam-for-linux and shellcheck (I'm not really recommending set -u btw)
  3. Globs and wildcards in the path will be expanded by the shell before rm is called, leading to some kind of apocalypse probably.

You may think that the code as-written can't be subject to such problems. But a future refactoring elsewhere could render this unsafe.

If you agree I can send a PR adding some safety catches. What do you think?

BASH_VERSION is wrong somehow

$ bashvm use 4.0 --install
$ echo $BASH_VERSION
5.1.4(1)-release
$ LANG=C bash --version|sed -nr '1s/^.*, version (.*) .*/\1/p'
4.0.0(1)-release

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.