I have two bash functions: tsoc
and loopex
I have put them in a diffchecker so you can see that they are almost identical: https://www.diffchecker.com/nygtg1l4
When I run loopex
, I get the type of output I want: "Orphaned" or "Passed" for each item in the outer loop. However, for tsoc
, a function that is nearly identical, I get "Orphaned" printed after every line, whether "Passed" or "Orphaned", which is not desired.
Outputs
loopex (correct)
$ loopex
Checking 1: Orphaned
Checking 2: Orphaned
Checking 3: Passed
Checking 4: Orphaned
Checking 5: Orphaned
tsoc (incorrect)
$ tsoc
Checking ./assignments/documents/Module2.pdf: Passed
Orphaned
Checking ./announcements.html: Passed
Orphaned
Checking ./projects.html: Passed
Orphaned
Checking ./assignments1.html: Passed
Orphaned
Checking ./lectures1.html: Passed
Orphaned
Checking ./random.txt: Orphaned
Checking ./index.html: Passed
Orphaned
Checking ./news.html: Passed
Orphaned
As you can see, Orphaned is printing after every line in tsoc
and I'm absolutely baffled as to why. The only think I can think of is that piping to a while loop is somehow breaking the logic of the continue statement. However, in the manpage for continue, it states that it works for 'while' and 'for' loops.
I've been at this for hours and I'm at my wits end. Any light you can shed on the situation would be greatly appreciated.