Skip to content

Instantly share code, notes, and snippets.

@gavinwahl
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavinwahl/a914384e79d7a3856bcc to your computer and use it in GitHub Desktop.
Save gavinwahl/a914384e79d7a3856bcc to your computer and use it in GitHub Desktop.
tmpd = do
tmp <- var $ glob "/tmp/tmp/"
today <- function $ cmd "date" ["+%F"]
when_ (not_ $ dirExists tmp) $ mkdir tmp
cd tmp
i <- var $ lit "1"
dir <- var $ today
while_ (dirExists dir) $ do
set i $ readVar i + 1
set dir $ today <> lit "." <> readVar i
mkdir dir
cd dir
_V0=/tmp/tmp/
_F1() {
date "+%F"
}
if ! "$(test "-d" "$_V0")"
then
mkdir "$_V0"
fi
cd "$_V0"
_V2="1"
_V3="$(_F1)"
while test "-d" "$_V3"
do
_V2="$(expr "$_V2" "+" "1")"
_V3="$(_F1)"".""$_V2"
done
mkdir "$_V3"
cd "$_V3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment