#!/bin/bash ENTRY=$1 PROPERTY=$2 # Complain and exit if we weren't given a path and a property: if [[ ! $ENTRY || ! $PROPERTY ]]; then echo "usage: addprop " exit 64 fi if [ ! -e $ENTRY ]; then echo "$ENTRY not found" exit 66 fi echo "marking $ENTRY with $PROPERTY" # If the target is a plain file instead of a directory, make it into # a directory and move the content into $ENTRY/index: if [ -f $ENTRY ]; then echo "making $ENTRY into a directory, moving content to" echo " $ENTRY/index" # Get a safe temporary file: TEMPFILE=`mktemp` mv $ENTRY $TEMPFILE mkdir $ENTRY mv $TEMPFILE $ENTRY/index fi if [ -d $ENTRY ]; then touch $ENTRY/$PROPERTY else echo "something broke - why isn't $ENTRY a directory?" file $ENTRY fi echo kthxbai exit 0