Skip to content
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

cd // results in infinite loop #125

Closed
greg9q opened this issue Aug 12, 2016 · 7 comments
Closed

cd // results in infinite loop #125

greg9q opened this issue Aug 12, 2016 · 7 comments
Assignees
Labels
Milestone

Comments

@greg9q
Copy link

greg9q commented Aug 12, 2016

Using version 0.1.0 on my Mac. cd // gets caught here:

    while [[ "$PWD" != "/" && "$PWD" != "$home" ]]
    do
      _file="$PWD/.env"
      if [[ -e "${_file}" ]]
      then echo "${_file}"
      fi
      builtin cd ..
    done

Once PWD gets to // it stays there and keeps looping. Ran into this since my Anaconda install likes to put these // prefixes at the start of path names. Kind of weird, but they are valid paths.

@dasJ
Copy link
Contributor

dasJ commented Aug 12, 2016

Is this problem still there in 0.2.0? I rewrote most of this logic.

In the meantime: https://youtu.be/LDZX4ooRsWs

@dasJ dasJ self-assigned this Aug 12, 2016
@greg9q
Copy link
Author

greg9q commented Aug 12, 2016

Yes. Here's the loop where it get's stuck now:

        while [ "${PWD}" != "${_mountpoint}" ]; do
            _file="${PWD}/${AUTOENV_ENV_FILENAME}"
            if [ -f "${_file}" ]; then
                if [ -z "${_hadone}" ]; then
                    echo -n ${_file}
                    _hadone='1'
                else
                    echo -n "
${_file}"
                fi
            fi
            command -v chdir >/dev/null 2>&1 && chdir .. || builtin cd ..
        done

Thanks much for the link.

@greg9q
Copy link
Author

greg9q commented Aug 13, 2016

@dasJ dasJ added this to the 0.3.0 milestone Aug 14, 2016
@dasJ dasJ removed the waiting label Aug 14, 2016
@ashokrajar
Copy link
Contributor

ashokrajar commented Aug 23, 2016

Need support for symlinked directory too.

Same behaviour occurs when you try to switch into a soft linked directory from other mount point.

eg:
OS : Mac OSX
autoenv : 1.0.0
Shell : zsh

ln -s /Volumes/Disk1/code /Users/ashokraja/code
cd /Users/ashokraja/code/autoenv


df /Users/ashokraja/code
++ awk 'END{print $NF}'
++ _mountpoint=/Volumes/MDRIVE
++ _hadone=
++ '[' /Users/ashokraja/code '!=' /Volumes/Disk1 ']'
++ _file=/Users/ashokraja/code/.env
++ '[' -f /Users/ashokraja/code/.env ']'
++ command -v chdir
++ builtin cd ..
++ '[' /Users/ashokraja '!=' /Volumes/Disk1 ']'
++ _file=/Users/ashokraja/.env
++ '[' -f /Users/ashokraja/.env ']'
++ command -v chdir
++ builtin cd ..
++ '[' /Users '!=' /Volumes/Disk1 ']'
++ _file=/Users/.env
++ '[' -f /Users/.env ']'
++ command -v chdir
++ builtin cd ..
++ '[' / '!=' /Volumes/Disk1 ']'
++ _file=//.env
++ '[' -f //.env ']'
++ command -v chdir
++ builtin cd ..
++ '[' / '!=' /Volumes/MDRIVE ']'
++ _file=//.env
++ '[' -f //.env ']'
++ command -v chdir
++ builtin cd ..
...
....

Infinite loop.

@dasJ dasJ modified the milestones: 0.2.1, 0.3.0 Aug 26, 2016
@dasJ
Copy link
Contributor

dasJ commented Aug 26, 2016

@ashokrajar Can you please open a new issue for that? It's caused by another problem.

@dasJ
Copy link
Contributor

dasJ commented Aug 26, 2016

@greg9q Can you please test the current master?

@dasJ dasJ added the waiting label Aug 26, 2016
@dasJ dasJ mentioned this issue Aug 26, 2016
5 tasks
@dasJ dasJ removed the waiting label Aug 29, 2016
@dasJ dasJ closed this as completed Aug 29, 2016
@greg9q
Copy link
Author

greg9q commented Aug 29, 2016

@dasJ Yes, current master now works. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants