Sha256: e18adb4d1bcd56bffe92d5b318add600b6a9fcdd9826ad0907eff9681c4d63b7

Contents?: true

Size: 1.46 KB

Versions: 50

Compression:

Stored size: 1.46 KB

Contents

#!/bin/bash
#Script header edition
#@author Aldo

#Constants
installer_file_path=$(readlink -f $0)
installer_folder_path=`dirname "$installer_file_path"`


#Functions


msg () {
	echo "#################################"
	echo $1
}


#Main Program

msg "Starting set scripts header"

echo "Installer path:" $installer_file_path


#Look for params

msg "Detecting ruby enviroment"

if [ $1 ]
  then {
	echo "Ruby enviromet specified by param"
	ruby_env=$1
  } else {
	ruby_env=`which ruby`
  }
fi

echo "Ruby enviroment:" $ruby_env


msg "Writing scripts header"
echo ""
for file in `ls $installer_folder_path/` ; do


	if [ ! -f $installer_folder_path/$file ];
	then
		continue
	fi

	if [[ $file =~ .sh$ ]]
	then
		continue
	fi

	if [ $installer_folder_path/$file == $installer_file_path ];
	then
		continue
	fi


	printf $file"\n"

	#Create temporal file
	temporal_path=$installer_folder_path/$file"_temp"

	if [ -f $temporal_path ];
	then
		echo "File $temporal_path exists."
		rm $temporal_path
	fi

	touch $temporal_path

	#Read file
	file_path=$installer_folder_path/$file

	SAVEIFS=$IFS
	IFS=$(echo -en "\n\b")

	while read line
	do
		#Look for Pattern !/usr/bin/env ruby
		if [[ $line =~ ^#!/usr/bin/env ]]
		then
			scriptheader="#!/usr/bin/env"
			line="${scriptheader} ${ruby_env}"
		fi
		echo $line >> $temporal_path
	done < $file_path

	IFS=$SAVEIFS

	#Replace original file
	cp $temporal_path $file_path

	#Remove temporal file
	rm $temporal_path

done


msg "Complete"
exit 0







Version data entries

50 entries across 50 versions & 3 rubygems

Version Path
social_stream-presence-0.8.0 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-0.21.4 presence/ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.7.5 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.7.4 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-0.21.3 presence/ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.7.3 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-0.21.2 presence/ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.7.2 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-0.21.1 presence/ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.7.1 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-0.21.0 presence/ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.7.0 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.6.3 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-0.20.2 presence/ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.6.2 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-0.20.1 presence/ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.6.1 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-0.20.0 presence/ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.6.0 ejabberd/ejabberd_scripts/set_script_header.sh
social_stream-presence-0.5.4 ejabberd/ejabberd_scripts/set_script_header.sh