#!/bin/bash
## use aliases in a for loop (to show it wouldn't work).
## author: Xiaoxu Guan at LSU HPC.
## Jan 30, 2016

echo

shopt -s expand_aliases

alias cdwf="cd /work/$USER/"


cdwf &&  pwd && echo  && echo "$(ls)"

unalias cdwf

# alias works at this point.


# test aliases in a loop:
echo -e  "\ntest aliases in a loop"

for int in {0..2} ; do
    echo "int = $int"
    alias cdpf="cd /project/$USER/"
    cdpf && pwd && echo "$(ls)" && echo "alias worked" || echo "alias failed"
    echo 
done
# Definition of alias failed in a loop that is a compound constrcut.


echo
