Skip to content

Commit

Permalink
basic impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrizhu committed Nov 3, 2024
1 parent 872845f commit b177cde
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion try
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ try() {
findmnt --real -r -o target -n >>"$DIRS_AND_MOUNTS"
sort -u -o "$DIRS_AND_MOUNTS" "$DIRS_AND_MOUNTS"

# Setup excluded entries
excldir="$SANDBOX_DIR/excldir"
if [ -n "$EXCL_ENTS" ]
then
OLDIFS=$IFS
IFS=":"
mkdir "$excldir"
for exclent in $EXCL_ENTS
do
whiteout_file="$SANDBOX_DIR/excldir/$(realpath "$exclent")"
mkdir -p "$(dirname "$whiteout_file")"
mknod "$whiteout_file" c 0 0
done
IFS=$OLDIFS
fi

# Calculate UPDATED_DIRS_AND_MOUNTS that contains the merge arguments in LOWER_DIRS
UPDATED_DIRS_AND_MOUNTS="$(mktemp --suffix ".try-$EXECID")"
export UPDATED_DIRS_AND_MOUNTS
Expand All @@ -81,6 +97,11 @@ try() {
OLDIFS=$IFS
IFS=":"

if [ -d "$excldir/$mountpoint" ]
then
new_mountpoint="$excldir/$mountpoint"
fi

for lower_dir in $LOWER_DIRS
do
temp_mountpoint="$lower_dir/upperdir$mountpoint"
Expand Down Expand Up @@ -614,7 +635,7 @@ NO_COMMIT="interactive"
# Includes all patterns given using the `-i` flag; will be used with `grep -f`
IGNORE_FILE="$(mktemp --suffix ".try-$EXECID")"

while getopts ":yvnhxi:D:U:L:" opt
while getopts ":yvnhxi:D:U:L:E:" opt
do
case "$opt" in
(y) NO_COMMIT="commit";;
Expand All @@ -632,6 +653,12 @@ do
fi
LOWER_DIRS="$OPTARG"
NO_COMMIT="quiet";;
(E) if [ -n "$EXCL_ENTS" ]
then
error "the -E option has been specified multiple times" 2
fi
EXCL_ENTS="$OPTARG"
NO_COMMIT="quiet";;
(v) echo "$TRY_COMMAND version $TRY_VERSION" >&2
exit 0;;
(U) if ! [ -x "$OPTARG" ]
Expand Down

0 comments on commit b177cde

Please sign in to comment.