Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6385841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:57:00+00:00 2026-05-25T02:57:00+00:00

I can’t seem to find the difference between a script run two different ways.

  • 0

I can’t seem to find the difference between a script run two different ways.

Here’s the script (named test.sh):

#! /bin/bash
printf "%b\n" "\u5A"

When the script is sourced:

. test.sh
> Z         ## Result I want ##

When the script is run:

./test.sh
> \u5A      ## Result I get ##

I want the run script to give the results of the sourced script… what setting do I need to set/change?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:57:00+00:00Added an answer on May 25, 2026 at 2:57 am

    HAHA!!! I finally traced down the problem! Read ahead if interested (leave the page if not).

    These are the only command that will translate \u properly:

    . ./test.sh                         ## Sourcing the script, hash-bang = #! /bin/sh
    . ./test.bash                       ## Sourcing the script, hash-bang = #! /bin/bash
    ./test                              ## Running the script with no hash-bang
    

    All of the following produce identical results in that they do NOT translate \u:

    ./test.sh                           ## Script is run from an interactive shell but in a non-interactive shell
    
    ## test.sh has first line: #! /bin/sh
    /bin/sh -c "./test.sh"              ## Running the script in a non-interactive sh shell
    /bin/sh -lc "./test.sh"             ## Running the script in a non-interactive, login sh shell
    /bin/sh -c ". ./test.sh"            ## Sourcing the file in a non-interactive sh shell
    /bin/sh -lc ". ./test.sh"           ## Sourcing the file in a non-interactive, login sh shell
    
    ## test.bash has first line: #! /bin/bash
    /bin/bash -c "./test.bash"          ## Running the script in a non-interactive bash shell
    /bin/bash -lc "./test.bash"         ## Running the script in a non-interactive, login bash shell
    /bin/bash -c ". ./test.bash"        ## Sourcing the file in a non-interactive bash shell
    /bin/bash -lc ". ./test.bash"       ## Sourcing the file in a non-interactive, login bash shell
    
    ## And from ***tripleee*** (thanks btw):
    /bin/sh --norc; . ./test.sh         ## Sourcing from an interactive sh shell without the ~/.bashrc file read
    /bin/bash --norc; . ./test.bash     ## Sourcing from an interactive bash shell without the ~/.bashrc file read
    

    The only way to get proper translation is to run the script without a hash-bang… and I finally figured out why! Without a hash-bang my system chooses the default shell, which btw is NOT /bin/bash… it turns out to be /opt/local/bin/bash… two different versions of bash!

    Finally, I removed the OSX /bin/bash [v3.2.48(1)] and replaced it with the MacPorts /opt/local/bin/bash [v4.2.10(2)] and now running the script works! It actually solved about 10-15 other problems I’ve had (like ${var,,}, read sN1 char, complete -EC "echo ' '", and a host of other commands I have scattered throughout my scripts, ~/.bashrc amd ~/.profile). Honestly, I really should have noticed when my scripts using associative arrays suddenly crapped out on me… how stupid can I get!?

    I’ve been using bash v4 for a looong time now, and my Lion upgrade went and down-graded bash back to v3 (get with the program Apple!)… ugh, I feel so ashamed! Everyone still using bash v3, upgrade!! bash v4 is has many, many beautiful upgrades over version 3. Type bash --version to see what version you are running. One advantage is now bash can translate \uHEX into Unicode!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you tell me what is the difference between abstraction and information hiding in
Can anyone point me out or explain what is the difference between android Home
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can a LINQ enabled app run on a machine that only has the .NET
Can I use the following across all browsers? <a href=# onclick=doSomething()>Click here.</a> Is this
Can anyone help me trying to find out why this doesn't work. The brushes
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Can somebody point me to a resource that explains how to go about having
Can you cast a List<int> to List<string> somehow? I know I could loop through
can you recommend some good ASP.NET tutorials or a good book? Should I jump

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.