$USER already set when wanting to read username from user

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I made this code



while [ -z "$USER" ]; do
>&2 echo -n 'Your desired User : '
read USER
done


But this doesn't work because $USER is taken from the current user running the script, which isn't what I want.



How can I avoid this in the future for the $USER variable and also other variables where this could happen? Like $PATCH or similar







share|improve this question


























    up vote
    0
    down vote

    favorite












    I made this code



    while [ -z "$USER" ]; do
    >&2 echo -n 'Your desired User : '
    read USER
    done


    But this doesn't work because $USER is taken from the current user running the script, which isn't what I want.



    How can I avoid this in the future for the $USER variable and also other variables where this could happen? Like $PATCH or similar







    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I made this code



      while [ -z "$USER" ]; do
      >&2 echo -n 'Your desired User : '
      read USER
      done


      But this doesn't work because $USER is taken from the current user running the script, which isn't what I want.



      How can I avoid this in the future for the $USER variable and also other variables where this could happen? Like $PATCH or similar







      share|improve this question














      I made this code



      while [ -z "$USER" ]; do
      >&2 echo -n 'Your desired User : '
      read USER
      done


      But this doesn't work because $USER is taken from the current user running the script, which isn't what I want.



      How can I avoid this in the future for the $USER variable and also other variables where this could happen? Like $PATCH or similar









      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 21 '17 at 9:19









      Kusalananda

      105k14209326




      105k14209326










      asked Oct 21 '17 at 8:48









      Freedo

      407417




      407417




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          Use lower-case variable names, or know exactly what upper-case variable names to avoid using.



          For non-environment variables (i.e. shell variables), just use lower-case:



          while [ -z "$user" ]; do
          read -p 'User name: ' user
          done





          share|improve this answer




















          • lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
            – Freedo
            Oct 21 '17 at 8:53










          • @Freedo Not really, unless you explicitly want to change system environment variables like PATH etc.
            – Kusalananda
            Oct 21 '17 at 8:55










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399503%2fuser-already-set-when-wanting-to-read-username-from-user%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          Use lower-case variable names, or know exactly what upper-case variable names to avoid using.



          For non-environment variables (i.e. shell variables), just use lower-case:



          while [ -z "$user" ]; do
          read -p 'User name: ' user
          done





          share|improve this answer




















          • lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
            – Freedo
            Oct 21 '17 at 8:53










          • @Freedo Not really, unless you explicitly want to change system environment variables like PATH etc.
            – Kusalananda
            Oct 21 '17 at 8:55














          up vote
          2
          down vote



          accepted










          Use lower-case variable names, or know exactly what upper-case variable names to avoid using.



          For non-environment variables (i.e. shell variables), just use lower-case:



          while [ -z "$user" ]; do
          read -p 'User name: ' user
          done





          share|improve this answer




















          • lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
            – Freedo
            Oct 21 '17 at 8:53










          • @Freedo Not really, unless you explicitly want to change system environment variables like PATH etc.
            – Kusalananda
            Oct 21 '17 at 8:55












          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          Use lower-case variable names, or know exactly what upper-case variable names to avoid using.



          For non-environment variables (i.e. shell variables), just use lower-case:



          while [ -z "$user" ]; do
          read -p 'User name: ' user
          done





          share|improve this answer












          Use lower-case variable names, or know exactly what upper-case variable names to avoid using.



          For non-environment variables (i.e. shell variables), just use lower-case:



          while [ -z "$user" ]; do
          read -p 'User name: ' user
          done






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 21 '17 at 8:51









          Kusalananda

          105k14209326




          105k14209326











          • lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
            – Freedo
            Oct 21 '17 at 8:53










          • @Freedo Not really, unless you explicitly want to change system environment variables like PATH etc.
            – Kusalananda
            Oct 21 '17 at 8:55
















          • lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
            – Freedo
            Oct 21 '17 at 8:53










          • @Freedo Not really, unless you explicitly want to change system environment variables like PATH etc.
            – Kusalananda
            Oct 21 '17 at 8:55















          lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
          – Freedo
          Oct 21 '17 at 8:53




          lol so dumb, I don't know why I didn't thought about that...I guess it doesn't worth the effort to use uppercase variables in this case right?
          – Freedo
          Oct 21 '17 at 8:53












          @Freedo Not really, unless you explicitly want to change system environment variables like PATH etc.
          – Kusalananda
          Oct 21 '17 at 8:55




          @Freedo Not really, unless you explicitly want to change system environment variables like PATH etc.
          – Kusalananda
          Oct 21 '17 at 8:55

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399503%2fuser-already-set-when-wanting-to-read-username-from-user%23new-answer', 'question_page');

          );

          Post as a guest













































































          NI4Sgyc9c5tLO,fL6NE1EYaAnA
          5Tt5ZV,arkMix534slXMfDJu,BrdE

          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          How many registers does an x86_64 CPU actually have?

          Displaying single band from multi-band raster using QGIS