You misunderstand what &&/|| means - it's not a ternary expression.
&& means "if the last command you executed succeeded" while
|| means "if the last command you executed failed"
That "last command executed" part is important. It doesn't say "the command before the first || or && on the line", as would be the case in a similar ternary expression structured as test ? exit : echo, it says the last command executed so in your code:
test -f "$1" || echo "$1 is not a file" && exit 1
it reads as pseudo-code:
IF test fails (i.e. $1 is not a file) THEN
IF echo ... succeeds THEN
exit 1
ENDIF
ELSE (i.e. test succeeded and $1 is a file)
exit 1
ENDIF
I think what you probably meant to write is:
test -f "$1" || { ret="$?"; echo "$1 is not a file" >&2; exit "$ret"; }
which means:
IF test fails (i.e. $1 is not a file) THEN
save it's exit status in ret
echo ...
exit with the failure exit status from test
ENDIF
if ... then ...; else ...; fi.&&/||in place ofifstatements. They may be easier to read, but they're much harder to understand. Their semantics can easily lead to unexpected interactions between the various commands involved; see this question and this BashPitfalls entry.test -f ...sets exit code 0, which means that the command after||is not performed. This is by design of the||statement separator. Why did you expect something different?