#!/usr/bin/perl ############################################################################### # # # Name : copy_variables # # Author : Chris Koeritz # # Rights : Copyright (C) 1996-$now by Author # # # # Purpose: # # # # creates the variable files "variable.bat" and "variable.cmd" from the # # single source file of "variable.one". # # # ############################################################################### # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # # Software Foundation; either version 2 of the License or (at your option) # # any later version. See: "http://www.gruntose.com/Info/GNU/GPL.txt" for a # # version of the License. Please send any updates to "fred@gruntose.com". # ############################################################################### require "importenv.pl"; $GENERADIR =~ s/\\/\//g; $SHELLDIR =~ s/\\/\//g; $YETI_DIR =~ s/\\/\//g; # create our generated shells directory if it's not already. if (! -d $GENERADIR) { mkdir $GENERADIR; } $filename = "$GENERADIR/variable.bat"; &make_copy($filename); $filename = "$GENERADIR/variable.cmd"; &make_copy($filename); #temp printf "\n\n"; exit 0; # make_copy: this function does the actual copying of the source file # into the output file passed in. sub make_copy { $output_file = @_[0]; $header = "\@echo off\r rem ======================================================================\r rem DO NOT EDIT!\r rem %FILENAME% should be identical\r rem (except for these warning lines)\r rem to the file variable.one.\r rem ======================================================================\r "; $variables = "$SHELLDIR/variable.one"; $header_copy = $header; $header_copy =~ s/%FILENAME%/$filename/; printf "writing $output_file...\n"; open(INPUT, "<$variables"); open(OUTPUT, ">$output_file"); print OUTPUT "$header_copy"; while () { print OUTPUT $_; } }