On Fri, Aug 05, 2022 at 11:05:50AM +0530, Ishaan Mahajan wrote: > Sorry for another email but this is what it looks like now - RUN sudo > adduser --shell $USERSHELLPATH --disabled-password $USERNAME && \ > However, I am still running into the same problem.
You need to listen to what people have already said. We need to know what's IN THOSE VARIABLES. You need to double-quote all variable expansions. "$USERNAME" with quotes instead of $USERNAME without quotes. And, as Cindy pointed out, you need to proofread for missing dollar signs and other typos. Finally, SHOW US the actual problem, in context. Don't just describe it or paraphrase it. Actually COPY the text from your terminal, showing your shell prompt, the command you typed, and the full output of the script. In fact, for short scripts, what I like to do is run "cat thescript" as a shell command, and then run the script as a second shell command. Then I copy the entire thing, from the "cat" all the way down to the bottom of the script's output, and include all of that in the message. That way people can see the script, and see its output, all together at one time. Here's an example. Let's say I have a script that's supposed to divide a number by 2, and write the result. And suppose it's got a couple bugs in it. I might ask for help like this: "My script doesn't work. If I enter an odd number, I don't get the right answer. And if I enter more than one number, it only divides the first one. Why?" unicorn:~$ cat foo #!/bin/bash half() { echo $(( $1 / 2 )) } read -r -p "Enter a number: " number half $number unicorn:~$ ./foo Enter a number: 15 7 unicorn:~$ ./foo Enter a number: 6 8 3 Here, you can see the whole script, and the results of running it twice, DEMONSTRATING the problem. So now, you can see what I'm seeing. You know exactly what I gave as input. You know exactly what the script wrote as output. Now you can actually try to point out the bugs in my script. There are at least three: 1) The / operator is integer division, not floating point. If the expected result of the first run is 7.5 then I need to use bc or awk or something to do the floating point division. 2) Failure to quote $number means the input gets split into multiple words when it's passed to the function. $1 will contain the first word, and $2 the second word, etc. Of course, there's more to it than that. You can't rely on this to do ONLY word splitting. If the user types * then the function will receive a bunch of filenames as its arguments. Shells SUCK. unicorn:~$ ./foo Enter a number: * ./foo: line 4: 00INDEX: value too great for base (error token is "00INDEX") 3) There is no part of my script that handles multiple inputs as multiple divisions. It just isn't WRITTEN to do it. The entire thing needs to be redone, with proper and safe input word splitting, and a loop. Sorry for the small tangent, but since bug number 2 in my script is also present in yours, despite our previous warnings which you ignored, maybe seeing it in action might help you.