| delorie.com/archives/browse.cgi | search |
| X-Spam-Check-By: | sourceware.org |
| Mime-Version: | 1.0 |
| Date: | Sun, 6 Aug 2006 07:46:07 -0800 |
| Message-ID: | <74382BAFEAA.000000D2wolfpack@inbox.com> |
| From: | Shane <wolfpack AT inbox DOT com> |
| Subject: | Checking XCOPY Exit Value in Cygwin Bash |
| To: | cygwin AT cygwin DOT com |
| X-Mailer: | INBOX.COM |
| X-IWM-ACU: | Y2yk0ZnJ7y7KVqJ-MvSnEgfTBSI092vQgHcG-5PdbB4-VuZ1wocEj6rz_FYQ tEO1CygVFUPNzaLg89nFAuyT3NdF1TNAuvWJE5HzS5MNk72rWWqVWb8OdDyP qz6ppuziUgeTh_cca |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| X-MIME-Autoconverted: | from quoted-printable to 8bit by delorie.com id k76FkGjl031875 |
Hi all,
I am writing a automated build script for my project that will be run under cygwin. I will copy my updated source files to the build directory and if there are updated files, the executables will be built. To copy the source files, I had to use XCOPY since the directory structure should be preserved in the destination directory also. To copy only the updated files, I used the /D switch for XCOPY. Now since I want to execute the source compile only if files in the build directory have been updated, I have to use the exit codes of XCOPY inside the script. I tried checking the value of $! after executing XCOPY but it didnt work. I couldn't find a solution in the internet too. Currently I am piping the standard output to a file and checking if the number of files copied is 0 or not. But I think this is not an elegant solution. This is what I am doing now.
[script]
copied=false
# Helper Function
copy_files()
{
echo copying *.$1 files in $2 to $3\\$2
xcopy /DSYI $2\\*.$1 $3\\$2 | tee copy.log
while read amount ; do
if [ ${amount::1} != "0" ]; then
copied=true;
fi
done < copy.log
}
cd ../source
copy_files h . ..\\build
copy_files c . ..\\build
copy_files cpp . ..\\build
rm -f copy.log
! $copied && echo "Files up-to-date. Skipping build" && exit 0
cd ../build
# Start the Build Process
[/script]
Can you please provide me a way of checking the XCOPY exit code: reference [http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true] within Bash?
Thank you for your time.
Shane
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |