What does '-L $path' mean in bash

What does -L $package_path mean or do in the following code?

PACKAGES=(a b c)
COLORS=(32 33 34 35 36 32)
PACKAGE_LINK_PATHS=(false false false false false false)
SECONDS=0
esc=$(printf '\e')
for index in "${!PACKAGES[@]}"
do package_name="${PACKAGES[$index]}" package_path="node_modules/somewhere/${package_name}" color_code="${COLORS[$index]}" if [ -L $package_path ]; then if [ $unlinkPackages = true ]; then printf "Unlinking ${package_name}\n" else # Cache the currently linked package path PACKAGE_LINK_PATHS[$index]=$(readlink $package_path) fi rm -rf $package_path fi
done

1 Answer

if [ -L

means "test for symlink".

The printf "Unlinking ${package_name}\n" is a big clue ;)

And man bash explains it too (search for -L):

-L file True if file exists and is a symbolic link.
5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like