file=todo.list
line=2
perl -F, -pi -lapse '
$F[0] = 1 if $. == $line;
$_ = join ",", @F' -- -line="$line" -- "$file"
Or with gawk:
file=todo.list
line=2
gawk -i /usr/share/awk/inplace.awk -v line="$line" -F, -v OFS=, -e '
NR == line {$1 = 1}
{print}' -E /dev/null "$file"
With GNU sed, you could do:
sed -i -e "${line}s/^[^,]*/1/" -- "$file"
But you'd have to sanitise $line (make sure it contains a sequence of [0123456789] characters) beforehand or otherwise, that would introduce an arbitrary command execution vulnerability.
With gawk, do not use -i inplace as gawk tries to load the inplace extension (as inplace or inplace.awk) from the current working directory first, where someone could have planted malware. The path of the inplace extension supplied with gawk may vary with the system, see the output of gawk 'BEGIN{print ENVIRON["AWKPATH"]}'
case "$1" in done) sed "$2s/^0,/1,/";;or what? How do we know?