recurssion via symbolic links without allowing system to act recursively?

I tried looking up combinations of the keywords "infinite loop links" in google before causing a recurring post here... but alas, I couldn't find much.

Cause: I've created an infinite loop, in a way, of directories.
Problem:

  1. I'm not sure if this will crash a backup program (trying to backup directories, namely OS X's Time Machine)
  2. I'm not sure if this will crash an app that's trying to index my system (such as Gnome-Do in my Linux system, or Spotlight in OS X)

What I did (in Mac OS X, but I assume it applies to any *nix based system with this command) is created a symbolic link, with ln -s, to another directory. I did this because I prefer using the command line, and a file-manager's "alias"es don't come in handy, since I can't CD into them (shortcuts in Windows Explorer, alias in Finder, not sure how nautilus creates GUI links).

Another thing I like about making a link with the command line (this is key to me), is that once you move through the link and into its destination, you don't have to worry that your parent directory has now changed. Let me clarify: if I'm in the command line and I jump across my file heirarchy using a link, than when I cd ../ back out to continue what I was doing I will be placed in the directory where the link was (not into the destination's parent). attached is an exmaple to clarify this.
this is the recursion I'm talking about:

ossPlatform/cpp/practice> pwd
/Users/Shared/Dropbox/crossPlatform/cpp/practice
ossPlatform/cpp/practice> ls -la
total 56
drwxr-xr-x  11 jzacsh  wheel   374 Sep 16 11:50 .
drwxr-xr-x   4 jzacsh  wheel   136 Sep 16 12:29 ..
lrwxr-xr-x   1 jzacsh  wheel    47 Sep 16 11:50 comp132 -> /Users/Shared/Dropbox/Public/edu/comp132/source
drwxr-xr-x   8 jzacsh  wheel   272 Jul 17 23:08 macex
-rw-r--r--   1 jzacsh  wheel   413 Jul 16 12:04 pg109.1.cpp
-rw-r--r--   1 jzacsh  wheel   631 Jul 16 12:23 pg109.2.cpp
-rw-r--r--   1 jzacsh  wheel   470 Jul 16 12:32 pg109.3.cpp
-rw-r--r--   1 jzacsh  wheel  1149 Jul 16 12:54 pg111.5.cpp
-rwxr-xr-x   1 jzacsh  staff  1061 Jul 13 00:51 pg91.cpp
-rwxr-xr-x   1 jzacsh  wheel  1335 Jul 16 08:57 pg95.cpp
drwxr-xr-x   3 jzacsh  wheel   102 Jul 16 23:27 unixex
ossPlatform/cpp/practice> cd comp132; ls -la
total 48
drwxr-xr-x  7 jzacsh  staff   238 Sep 16 12:18 .
drwxr-xr-x  6 jzacsh  staff   204 Sep 16 11:17 ..
-rw-r--r--@ 1 jzacsh  staff  6148 Sep 16 12:18 .DS_Store
-rw-r--r--@ 1 jzacsh  staff   235 Sep 16 11:14 hw_09-16.cpp
-rw-r--r--  1 jzacsh  staff   311 Sep 16 11:18 in09-16_circle.cpp
-rw-r--r--  1 jzacsh  staff  1400 Sep 16 11:21 in09-16_miPgall.cpp
lrwxr-xr-x  1 jzacsh  staff    48 Sep 16 11:51 practice -> /Users/Shared/Dropbox/crossPlatform/cpp/practice
orm/cpp/practice/comp132> cd practice; ls -la
total 56
drwxr-xr-x  11 jzacsh  wheel   374 Sep 16 11:50 .
drwxr-xr-x   4 jzacsh  wheel   136 Sep 16 12:29 ..
lrwxr-xr-x   1 jzacsh  wheel    47 Sep 16 11:50 comp132 -> /Users/Shared/Dropbox/Public/edu/comp132/source
drwxr-xr-x   8 jzacsh  wheel   272 Jul 17 23:08 macex
-rw-r--r--   1 jzacsh  wheel   413 Jul 16 12:04 pg109.1.cpp
-rw-r--r--   1 jzacsh  wheel   631 Jul 16 12:23 pg109.2.cpp
-rw-r--r--   1 jzacsh  wheel   470 Jul 16 12:32 pg109.3.cpp
-rw-r--r--   1 jzacsh  wheel  1149 Jul 16 12:54 pg111.5.cpp
-rwxr-xr-x   1 jzacsh  staff  1061 Jul 13 00:51 pg91.cpp
-rwxr-xr-x   1 jzacsh  wheel  1335 Jul 16 08:57 pg95.cpp
drwxr-xr-x   3 jzacsh  wheel   102 Jul 16 23:27 unixex
ractice/comp132/practice> cd comp132; pwd
/Users/Shared/Dropbox/crossPlatform/cpp/practice/comp132/practice/comp132

in an effort to show you the same listing twice (two show you i have two directories linking to each other), it even becomes clear with a final pwd that I am descended recursively down into the directories (probably not a good thing).

bottom line:

  • will I end up crashing applications (like those I named earlier), by having this? or do most applications not actually follow links (other than some burning software)?
  • can i get the features I enjoy out of these symbolic links in some other way, without causing this mess? or should I not worry about it and keep doing this?

Thanks in advance! :slight_smile: this forum's always been an awesome resource of info for me.

It depends on the application but most backup and indexing programs are smart enough to not follow symbolic links unless specifically instructed to do so. Some things like tar can even replicate them properly.

I'm still not entirely sure what you're doing with these symlinks though. Why not just put them in your home directory instead of scattering them throughout everything you use? Then you could do 'pushd ~/symlink' to cd comewhere, and 'popd' to get back. (pushd and popd are a directory stack.) It'd also let you make the links relative instead of absolute. And they'd be less deep than the things they link to, so recursion wouldn't be a problem.