diff and patch

I heartily recommend this article that describes using Linux’s patch and diff commands.

I had a .html file that needed updating. The code changes were done by a consultant, and he asked me to apply the patch. My usual feeling about anything I have not seen is to run, but this week I don’t have time to run, so I tried this patch, and it worked.

Here is what the patch looked like, and basically it put a check in to make sure someone filled in their zip code:


--- GenPayCCInfo.orig    2012-10-01 02:59:24.000000000 -0400
+++ GenPayCCInfo.html    2012-10-01 03:01:56.000000000 -0400
@@ -292,8 +292,10 @@
Field1 = GetFormField('GenPay', 'BillingAddress1');
Field2 = GetFormField('GenPay', 'BillingCity');
Field3 = GetFormField('GenPay', 'BillingState');
+Field4 = GetFormField('GenPay', 'BillingZipcode');

-if ((Field1.length <= 0) || (Field2.length <= 0) || (Field3.length <= 0))
+if ((Field1.length <= 0) || (Field2.length <= 0) || (Field3.length <= 0)
+  || (Field4.length <= 0))
{
window.alert('One of the required billing address fields is missing');

@@ -301,7 +303,9 @@
document.forms['GenPay'].elements['BillingAddress1'].focus();
else if (Field2.length <= 0)
document.forms['GenPay'].elements['BillingCity'].focus();
-  else document.forms['GenPay'].elements['BillingState'].focus();
+  else if (Field3.length <= 0)
+    document.forms['GenPay'].elements['BillingState'].focus();
+  else document.forms['GenPay'].elements['BillingZipcode'].focus();

return (false);
}

Advertisements

Leave a comment

Filed under Linux/Unix Utilities

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s