irods / irods_client_icommands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bash autocomplete for iCommands not working right

AGI-chandler opened this issue · comments

I have iRODS 4.3.0 installed and found the bash completion script here. After sourcing it, it kind of works, but it seems to always think I'm in my home directory. For example:

$ ipwd <enter>
/iplant/home/chandles
$ ils <enter>
/iplant/home/chandles:
  C- /iplant/home/chandles/analyses
$ ils <tab>(autocompletes to:)
$ ils analyses/<tab><tab>(lists possible options:)
analyses/Cloud_Shell_analysis1-2022-03-11-17-53-14.3/  analyses/Datahog_analysis1-2022-09-06-18-51-07.8/      analyses/Datahog_analysis1-2022-09-14-21-51-41.6/

$ ils analyses/ <enter>
/iplant/home/chandles/analyses:
  C- /iplant/home/chandles/analyses/Cloud_Shell_analysis1-2022-03-11-17-53-14.3
  C- /iplant/home/chandles/analyses/Datahog_analysis1-2022-09-06-18-51-07.8
  C- /iplant/home/chandles/analyses/Datahog_analysis1-2022-09-14-21-51-41.6
$ 

So it worked ok there, but if i icd into analyses directory it still think I'm in my home dir:

$ icd <enter>
$ icd <tab>(autocompletes to:)
$ icd ./analyses/ <enter>
$ icd <tab>(autocompletes to:)
$ icd analyses/ <enter>
No such directory (collection): /iplant/home/chandles/analyses/analyses
$ 

If I try to see above, it doesn't do anything:

$ ils ../<tab><tab>(nothing happens)

Actually it gets hung here and I have to ^C. Further, if I icd into our shared community data, it still thinks i'm in my home directory:

$ ils ../^C^C
$ ^C
$ ^C
$ ipwd
/iplant/home/chandles/analyses
$ icd ../../shared/agi_data <enter>
$ icd <tab>(autocompletes to:)
$ icd analyses/ <enter>
No such directory (collection): /iplant/home/shared/agi_data/analyses
$ ils <enter>
/iplant/home/shared/agi_data:
  C- /iplant/home/shared/agi_data/Asian_rice_pangenome_annotations
  C- /iplant/home/shared/agi_data/Dr_Lorieux_Data
  C- /iplant/home/shared/agi_data/HiFI_DATA
  C- /iplant/home/shared/agi_data/KAUST
$ ils H<tab>(nothing happens)

Hi @AGI-chandler - it looks like that script was written for 4.1.x (11 years ago!)... and the environment variable is now $IRODS_CWD since 4.2.0... so here is a diff that works for me - please test it out.

22,23c25,26
<   # Set irods current directory (weird!!)
<   export irodsCwd=$(ipwd)
---
>   # Set irods current directory
>   export IRODS_CWD=$(ipwd)
65a69,71
> 
>   # Unset irods current directory
>   unset IRODS_CWD

My goodness! Sorry about that, didn't realize I had ended up on such an ancient document. I'm glad to see you were able to easily update the code, however, and get it merged into main. With the new code, I can confirm the autocomplete is now working as expected. Thanks so much!