mheffner / awsam

Amazon Web Services Account Manager (modeled after 'rvm')
MIT License
117 stars 8 forks source link

aenv is not ruby? #35

Closed drbachler closed 6 years ago

drbachler commented 6 years ago

when trying to invoke aenv i get the following:

[~]$ aenv                                  
/usr/local/bin/aenv:22:in `load': /var/lib/gems/2.3.0/gems/awsam-0.2.0/bin/aenv:7: `$#' is not allowed as a global variable name (SyntaxError)
/var/lib/gems/2.3.0/gems/awsam-0.2.0/bin/aenv:7: syntax error, unexpected end-of-input, expecting ']'
if [ $# -lt 1 ]; then
      ^
        from /usr/local/bin/aenv:22:in `<main>'
[~]$ 
yosh-se commented 6 years ago

it seems aenv gets installed with a ruby-wrapper that tries to load the script as a ruby file.

mheffner commented 6 years ago

@drbachler Can you show me what the contents of /usr/local/bin/aenv is?

drbachler commented 6 years ago

Here is my /usr/bin/local/aenv

[~]$` cat /usr/local/bin/aenv 
#!/bin/bash

# Local Variables:
# mode: sh
# End:

if [ $# -lt 1 ]; then
    echo "Usage: aenv cmd [arg1 arg2 ...]"
    exit 1
fi

if [ -z "$AWSAM_ACTIVE_ACCOUNT" ]; then
    echo "Must pick an account first with `aem use <>`"
    exit 1
fi

ENV=$(raem --environ --account $AWSAM_ACTIVE_ACCOUNT --export)
eval $ENV
mheffner commented 6 years ago

Yeah, @yosh-se is probably right about the ruby-wrapper for non-ruby scripts: https://github.com/rubygems/rubygems/issues/88. I'll convert this to a ruby script and see if it fixes the problem.