-
Notifications
You must be signed in to change notification settings - Fork 17
Go to workspace directly if you provide the name #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…-system for workspaces with same name in different file-systems
cniethammer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure how high the value is of providing this as users can just do a simple cd $(ws_find NAME)
| WS_OPT+=" -F " | ||
| WS_OPT+=`echo ${2}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply
| WS_OPT+=" -F " | |
| WS_OPT+=`echo ${2}` | |
| WS_OPT+=" -F $2" |
| #!/bin/bash | ||
|
|
||
| if [ "$#" -eq 0 ]; then | ||
| echo "Usage: ws_go workspace [file-system]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usage info should go into separate function usage()
|
|
||
| if [ "$#" -eq 0 ]; then | ||
| echo "Usage: ws_go workspace [file-system]" | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use exit instead of return
| return | |
| exit 1 |
| @@ -0,0 +1,28 @@ | |||
| #!/bin/bash | |||
|
|
|||
| if [ "$#" -eq 0 ]; then | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Command line parsing should be improved - looks brittle to me. Also, should (optionally) allow -F as all other ws_* tools
| fi | ||
|
|
||
| WS_OPT= | ||
| if [ "$#" -lt 2 ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Command line parsing should be improved - looks brittle to me. Second place.
|
|
||
| WS_OPT= | ||
| if [ "$#" -lt 2 ]; then | ||
| NUMWS=`ws_find $1 | wc -l` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assign command line arguments to variables - what is $1 here in this scope?
| return | ||
| fi | ||
|
|
||
| WS_OPT= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you wanne WS_OPT to be later?
| WS_OPT= | |
| WS_OPT="" |
or
| WS_OPT= | |
| WS_OPT=() |
| NUMFS=`ws_list | grep "^ filesystem name : " | cut -d ":" -f2 | cut -d" " -f2 | sort -h | uniq | wc -l` | ||
| FSNAMES=`ws_list | grep "^ filesystem name : " | cut -d ":" -f2 | cut -d" " -f2 | sort -h | uniq | tr '\n' ' '` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calling ws_list multiple times - use cached output.
The parsing also looks complex, involving many pipes and different commands.
| if ws_list ${WS_OPT} | grep "^id: " | cut -d":" -f2 | cut -d" " -f2 | grep -q $1; then | ||
| cd `ws_find ${WS_OPT} $1` | ||
| else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why so over complicated. Rel on ws_find and do not call ws_list again...
| if ws_list ${WS_OPT} | grep "^id: " | cut -d":" -f2 | cut -d" " -f2 | grep -q $1; then | |
| cd `ws_find ${WS_OPT} $1` | |
| else | |
| ws_dir=$(ws_find ${WS_OPT} $1) | |
| if [[ -d $ws_dir ]]; then | |
| cd "$ws_dir" | |
| else |
| ws_list ${WS_OPT} | grep "^id: " | cut -d":" -f2 | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was obviously an error
| ws_list ${WS_OPT} | grep "^id: " | cut -d":" -f2 | |
| fi | |
| ws_list ${WS_OPT} | grep "^id: " | cut -d":" -f2 | |
| exit 1 | |
| fi |
|
actually ws_cd might be a better name? |
|
@holgerBerger bash completion with the currently chosen command line argument ordering will not work - the filesystem has to be an option before the name of a workspace |
|
I think the main problem is that should be a shell function and not a shell script, as it can not change parent shells CWD. |
I use something rather simple for this in my environment (not taking care of different file systems): Personal opinion: As a user has to include this into his environment (.bashrc, etc.) anyway, I do not see the added value of providing this as part of the installation. A user who can set up his environment should be able to write this small function, as well at this point ... |
optionally file-system for workspaces with same name in different file-systems