I have about 40 functions in shell script with most of the code being regex.
I need them to be converted to C#, including all the logic on them.
Most of them are simple as the sample below.
The payment will be split in 3 Milestones:
- 1) 2 Functions. To double check everything is been done in the way it should be.
- 2) 18 functions
- 3) 20 functions
The code must be very well commented/documented explained the logic on the regular expressions and logic.
The code must have unit tests, based on the input samples that will be made available.
The code must be on a git repository provided by me and code pushed daily.
I need this done ASAP.
Sample:
Original:
check_fstab_partition_options() {
local ID="$1"
local dir=`echo "$2" | sed "s/\/\{0,\}[ \t]\{0,\}$//g"`
local option="$3"
local filename="./fstab"
local line=""
[ ! -s "$filename" ] && return
local check_missing_shares=`cat $filename | egrep -v "^[[:blank:]]*#|^[[:blank:]]*$" | awk '{ print $2 }' | sed "s/\/\{0,\}[ \t]\{0,\}$//g" | sort -u | egrep -w $dir`
[ -z "$check_missing_shares" ] && {
return
}
local shares_and_options=`cat $filename | egrep -v "^[[:blank:]]*#|^[[:blank:]]*$" | awk '{ print $2";"$4 }' | tr " " "\n"`
for line in ${shares_and_options}; do
local share=`echo "$line" | cut -d";" -f1 | sed "s/\/\{0,\}[ \t]\{0,\}$//g"`
[ -n "$share" -a -n "$dir" ] && [ "$share" == "$dir" ] && {
local result=`echo "$line" | cut -d";" -f2 | egrep -w "$option"`
[ -z "$result" ] && {
verify "$ID" "1"
return
}
}
done
}
func_311() {
check_fstab_partition_options "4650" "/tmp" "nodev"
}
Converted:
public static string CheckFstabPartitionOptions(NixInstance instance, string partition)
{
var file = [login to view URL]("fstab");
if (file != null)
{
string _dir = [login to view URL](partition, "/", @"\/");
string _file = [login to view URL](file, @"^[\s\t#].*", [login to view URL], [login to view URL]);
string expr = [login to view URL](@" ", new string[] { @".*", _dir, @".*" });
Match matchLine = [login to view URL](file, expr, [login to view URL]);
if ([login to view URL])
{
string line = [login to view URL]([login to view URL], @"[\s\t]{1,}", " ");
string[] _line = [login to view URL](' ');
if ([login to view URL]() >= 3)
{
return _line[3];
}
}
}
return [login to view URL];
}
func_311(){
var options = CheckFstabPartitionOptions(instance, "/tmp");
if (![login to view URL](options))
{
if (![login to view URL](options, "nodev", [login to view URL]))
{
Verify(options);
}
}
}