Ugh ancient and absolutely typical of most distros: we call that kind of script "bashish", since it has a /bin/bash shebang, but is written for sh, only it relies on some bashisms, and doesn't even know clean sh. The use of eval is totally unnecessary. Personally I'd rewrite it for pure sh:

I'm not sure it's such a good idea for the user to manually set the fan speed, mind; the batch scan looked more useful. But you could use the above with /bin/sh symlinked to any shell conformant to POSIX, /bin/bb or dash for example, as well as bash.

If you're not going to exit from the first command if it fails, then move the checks of range below the case statement; but I would, even if you decide to use: || exit 0 (though exit status is typically useful to other components.) The exit status of the last command run (or in this case we exec for efficiency) will be the exit status of the script. If you don't want that, remove the exec and add exit 0 to end (though again, I'd question the validity of that.)

You're welcome, szpko; only it's not a "Bash script" any more, is it? ;) I'd edit the title/subject of OP and s/Bash/nvidia, as well as first line.

BTW, you shouldn't use unquoted globbing chars in script (unless you are trying to glob), however unlikely a match is; '[abc]' is a one-of char match in shell, when unquoted, and a string when it has '..' (or ".." but if it's literal, single-quoting is better afaic.) '*' and '?' are the other two to watch out for (as well ofc as spaces, and most punctuation, but not '.' or '/'.)

Didn't mean that there's no valid reason to tweak the fan speed; just that I'd be more interested in it being automatic. I didn't know nvidia default to 10% speed; I assumed it just varies with temperature. I have always got on with nvidia on Linux, so I'm curious now.

Thanks for putting in the legwork to find out more about it all, and taking the time to document.

Didn't mean that there's no valid reason to tweak the fan speed; just that I'd be more interested in it being automatic. I didn't know nvidia default to 10% speed; I assumed it just varies with temperature. I have always got on with nvidia on Linux, so I'm curious now.

For what it's worth, mine seems to default to 40, and I can't set it lower than 30, at least not via the nvidia-settings GUI.

I don't seem to have any sort of automagic happening (at least not within the temps I try to keep it, that's around 60°C at most... due to the noise levels it puts out, though I think it has gone beyond 70°C when I forget to adjust the speed; perhaps it would start fanning up beyond that, but I've not tested). So, I have to fiddle with coolbits to gain access (even though the fan tool-tip says one should never have to enable it).

Normally I set it down to 30, or let it be at 40-50 when I have things going that make heat happen. Sometimes even 60! At 100 it gets just silly.

This is with an Asus (EN)GTX 275._________________Kind Regards,
~ The Noob Unlimited ~

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses.
"""

RUNNING:
There are a few bugs which I haven't been able to solve, so observe carefully here:
- try to run from an already open terminal.
- try to end program using ctrl-C
- ensure that when finished, the box in nvidia-settings for the manual fan control is unticked!!!!!
"""
class Vector():
def __init__(self, x, y):
self.x = x
self.y = y