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

  • Home
  • SEARCH
  • 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 8444087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:18:52+00:00 2026-06-10T09:18:52+00:00

Has anything been done or is being planned to do about not being able

  • 0

Has anything been done or is being planned to do about not being able to turn off tilde substitution in the file commands (and some other commands too)? The latest I’ve read about this is http://wiki.tcl.tk/28190, but surely such a dangerous feature in a programming language can’t just be ignored? Wouldn’t it be as easy as letting the C function Tcl_TildeSubst() check for the existence of a global Tcl variable, and based on that do tilde expansion or not?

I often write Tcl scripts when a shell script isn’t enough, and a lot of time it includes comparing, copying, opening, removing and/or renaming files. Before I run a script I always use find to check for filenames that start with a tilde (~). I’m interested in hearing about how other Tcl programmers do it.

  • 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-06-10T09:18:53+00:00Added an answer on June 10, 2026 at 9:18 am

    Background

    Tilde substitution only happens at the point where Tcl is about to interpret a string as a filename, and it only happens when the first character of the string is a ~ (if the character is anywhere else, it is purely normal). There are exactly two substitutions that are done:

    1. If the ~ is on its own or is followed by a directory separator, it refers to your home directory (well, strictly to the directory named in the HOME environment variable, which defaults to your home directory).
    2. If the ~ is followed by anything else, the remainder of the filename up to the end of the string or the first directory separator (whichever comes first) is interpreted as a user name, and the ~user sequence is replaced by that user’s home directory (looked up using system utilities, so as listed in /etc/passwd on Unix, etc.)

    These features are disabled in safe interpreters, i.e., interpreters created with interp create -safe or with safe::interpCreate.

    Workaround

    The simplest way to stop a leading ~ from being a problem is to put ./ in front of it, and to always use the -directory option to glob (which is otherwise the only place in Tcl which can produce those sorts of filenames ambiguously; everywhere else it is presumably intended). Working with full filenames throughout usually leads to less problems overall (and I recommend never changing the working directory if possible; that just causes tremendous confusion).

    I wouldn’t consider safe interpreters to be a workaround, as they have many other restricted features as well (e.g., no access at all to the filesystem by default).

    The Policy Question

    As for the suggestion that it should be possible to disable it… That’s an interesting one, but it’s never been raised seriously with Tcl’s steering committee. The problem is that there’s a lot of code which assumes the current behavior; I think it wouldn’t be a particular problem to add a hack (e.g., a magic unsupported variable) to turn it off — there’s an interpreter context at the point where the expansion is done, so checking a Tcl variable to see whether to do it is trivial — but I’d personally worry a lot about what would be broken unexpectedly by such a change.

    Stack Overflow isn’t a very good environment for discussing such changes. You’d be better off asking on the tcl-core mailing list. Be aware that that’s a fairly robust debating chamber at times (though virtually always polite). An alternative (if you like IRC) is asking on #tcl on freenode.

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

Sidebar

Related Questions

Apologize if this particular problem has been answered already (a search didn't turn anything
Excuse me if this has indeed been asked before, I couldn't see anything that
I've tried searching through search engines,MSDN,etc. but can't anything. Sorry if this has been
has anybody done anything with scripts to parse an incoming e mail to a
Has anybody done anything like that? I need to import 3d objects, done in
By default it will not print out anything until the whole page has finished
I've done a few searches and not come up with anything, I'm sure it's
All my (home) CF learning has so far been done using Access as a
I have a file wich has about 12 millon lines, each line looks like
This is an interview question, the interview has been done. What things can make

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.