When I ls
a symlink to a directory, ls
just echoes the directory name.
➜ java-tutorial git:(main) ls -al
...
lrwxr-xr-x 1 josalvatorre staff 124 Jul 9 16:17 bazel-bin -> /private/var/tmp/_bazel_josalvatorre/0614f10b8ea3a5a2198fe449cfe635ce/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin
...
➜ java-tutorial git:(main) ls /private/var/tmp/_bazel_josalvatorre/0614f10b8ea3a5a2198fe449cfe635ce/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin
ProjectRunner ProjectRunner.jar-0.params ProjectRunner.jdeps _javac
ProjectRunner-native-header.jar ProjectRunner.jar-1.params ProjectRunner.runfiles external
ProjectRunner.jar ProjectRunner.jar_manifest_proto ProjectRunner.runfiles_manifest
➜ java-tutorial git:(main) ls bazel-bin
bazel-bin
Going off memory, I'm almost certain that this is not normal behavior. It's led to unexpected behavior when I enter commands I find online. What's going on here?
I'm using zsh on an M1 Mac. I use oh-my-zsh
.
Follow-Up
A few helpful people pointed out there there are dereferencing options -H
and -L
that do the trick. How would I make this the default behavior?
CodePudding user response:
It turned out that ls
was aliasing ls -G
. I just had to run unalias ls
.
➜ java-tutorial git:(main) ✗ unalias ls
➜ java-tutorial git:(main) ✗ type ls
ls is /bin/ls
➜ java-tutorial git:(main) ✗ ls bazel-bin
ProjectRunner ProjectRunner.jar-1.params ProjectRunner.runfiles_manifest libgreeter-hjar.jdeps libgreeter.jar-1.params
ProjectRunner-native-header.jar ProjectRunner.jar_manifest_proto _javac libgreeter-native-header.jar libgreeter.jar_manifest_proto
ProjectRunner.jar ProjectRunner.jdeps external libgreeter.jar libgreeter.jdeps
ProjectRunner.jar-0.params ProjectRunner.runfiles libgreeter-hjar.jar libgreeter.jar-0.params src
➜ java-tutorial git:(main) ✗ ls -G bazel-bin
bazel-bin
As some other folks mentioned, you could also force dereferencing via -H
and -L
.