I am making a template shell script for a project, one function that is a must is the ability to make a copy of a template configuration file as a new file. However, this is not going to be handled statically, I make and set a runtime variable ($modloader) that comes from the shell scripts file name and copies the template as this same name. I did some tests with static file names and cp works fine, but seems to fall apart when checking if the file is already present (line 5). If I run this in the terminal, it does not see the file it is checking for. I believe it is looking for it in a more literal context and doesn't 'understand' it's using a variable.
#!/bin/sh
modloader=basename -s .sh "$0"
if "./Settings/$modloader.ini"; then
cp "./Settings/Template.ini" "./Settings/$modloader.ini"
fi