Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Git and Xstow. I have a small shell script that parses the xstow.ini file and creates all the directories I have listed under the [keep-dirs] directive in order to prevent it from deleting empty directories or replacing them with links.

  #!/usr/bin/env bash
  
  #Read the keep directories from xstow.ini
  ini="$(<'xstow.ini')"
  IFS=$'\n' && ini=( ${ini} )
  ini=( ${ini[*]/\    =/=} )  # remove tabs before =
  ini=( ${ini[*]/=\   /=} )   # remove tabs after =
  ini=( ${ini[*]/\ =\ /=} )   # remove anything with a space around =
  
  #for each keep dir make sure it exists in the home dir
  for i in ${ini[@]}
  do
        if [[ $i =~ ^\ *dir ]]
        then
                eval $i
                mkdir $dir
        fi
  done


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: