#!/bin/bash

set -euo pipefail
indent=""

list_directory() {
	# subshell: cd and $indent are restored on return
	(
		cd "$1"
		indent="$indent  "
		for file in *; do
			[ -e $file ] || continue;
			echo "$indent$file"
			if [ -d "$file" ]; then
				list_directory "$file"
			fi
		done
	)
}

for arg; do
	echo "$arg:"
	list_directory "$arg"
done
