Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You're a card which will have to be dealt with.


comp / comp.lang.tcl / Re: missing command: file concat

SubjectAuthor
* missing command: file concataotto1968
+* Re: missing command: file concatgreg
|`* Re: missing command: file concatgreg
| `- Re: missing command: file concatgreg
+* Re: missing command: file concatRobert Heller
|`* Re: missing command: file concataotto1968
| `- Re: missing command: file concatRobert Heller
+- Re: missing command: file concatRich
`- Re: missing command: file concatgreg

1
Subject: missing command: file concat
From: aotto1968
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 12 May 2024 09:58 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: missing command: file concat
Date: Sun, 12 May 2024 11:58:19 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <v1q3rr$2lhl0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 12 May 2024 11:58:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2a81ba49424759bcb52edbe9ab9dec9d";
logging-data="2803360"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XjJSyEb6Jma6lQxgpQUkK5IaYQt5B5YE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:lyZD2QSYP2JD1dAjZrjaDhJX1J0=
Content-Language: en-US
View all headers

Hi,

the following code does *not* work :

set tmpFile [file join $TMP [ file normalize $F ]]

because *file normalize* will return an *absolute* path and *file join* will skip "$TMP" if
*absolute* path is found.

→ the GOAL is to create a new path with *prefix* "$TMP" using the local path separator

set tmpFile [file concat $TMP [ file normalize $F ]]

will solve this issue.

example:

TMP = /tmp
file normalize $F = /a/b

OLD: file join /tmp /a/b → /a/b
NEW: file concat /tmp /a/b → /tmp/a/b

mfg AO

Subject: Re: missing command: file concat
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 12 May 2024 12:21 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: missing command: file concat
Date: Sun, 12 May 2024 14:21:10 +0200
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <v1qc7m$2nfa0$1@dont-email.me>
References: <v1q3rr$2lhl0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 12 May 2024 14:21:10 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7bc0e0e9debab9b2eb419753abd2c4ad";
logging-data="2866496"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fQmaDwdgvitj39ZzP3vdJ0PpIDt8nEOU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:r22vYjP6wbaga3aevdy7POrarJI=
In-Reply-To: <v1q3rr$2lhl0$1@dont-email.me>
Content-Language: de-DE
View all headers

Am 12.05.24 um 11:58 schrieb aotto1968:
> Hi,
>
> the following code does *not* work :
>
> set tmpFile [file join $TMP [ file normalize $F ]]
>
> because *file normalize* will return an *absolute* path and *file join*
> will skip "$TMP" if
> *absolute* path is found.
>
> → the GOAL is to create a new path with *prefix* "$TMP" using the local
> path separator
>
> set tmpFile [file concat $TMP [ file normalize  $F ]]
>
> will solve this issue.
>
> example:
>
> TMP = /tmp
> file normalize $F = /a/b
>
> OLD: file join /tmp /a/b → /a/b
> NEW: file concat /tmp /a/b → /tmp/a/b
>
>
> mfg AO

# Idea
#https://wiki.tcl-lang.org/page/namespace+ensemble
#proc ::tcl::dict::get?

package require fileutil
proc ::tcl::file::concat {args} {
if {[llength $args] != 2} {
return -code error "This function expects exactly two arguments"
}
try {
file normalize [file join [lindex $args 0] [fileutil::stripPath
[lindex [file split [lindex $args 1 ]] 0] [lindex $args 1]]]
}
} namespace ensemble configure file -map \
[dict merge [namespace ensemble configure file -map] {concat
::tcl::file::concat}]

#Example
puts [file concat /tmp [pwd]]

#This Tcl script defines a procedure
#::tcl::file::concat that concatenates two file paths and normalizes the
result.

mfg
Gregor

Subject: Re: missing command: file concat
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Sun, 12 May 2024 12:37 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-3.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 12 May 2024 12:37:36 +0000
MIME-Version: 1.0
From: heller@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.17)
Subject: Re: missing command: file concat
In-Reply-To: <v1q3rr$2lhl0$1@dont-email.me>
References: <v1q3rr$2lhl0$1@dont-email.me>
Newsgroups: comp.lang.tcl
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <PsicnZhbXfyNJd37nZ2dnZfqnPGdnZ2d@giganews.com>
Date: Sun, 12 May 2024 12:37:36 +0000
Lines: 50
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-HaG5+lwm6ZlGo0se53eC8qu+rMcII3YFJDipM7rQmpbhaxFjT4wlZ69GgtWbvPHAAhp6Sg4zbCi/VV1!Kf9UGRCz42NEmOdZluWOtiLUJ5oL+ZQJhKsNLltt+cI2ojKn5/V7TW5DT0PaayWDjURrbgi4XUqU!qHU=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

At Sun, 12 May 2024 11:58:19 +0200 aotto1968 <aotto1968@t-online.de> wrote:

>
> Hi,
>
> the following code does *not* work :
>
> set tmpFile [file join $TMP [ file normalize $F ]]
>
> because *file normalize* will return an *absolute* path and *file join* will skip "$TMP" if
> *absolute* path is found.
>
> - the GOAL is to create a new path with *prefix* "$TMP" using the local path separator

Why would you really want to do that? Please explain your use case...

>
> set tmpFile [file concat $TMP [ file normalize $F ]]
>
> will solve this issue.
>
> example:
>
> TMP = /tmp
> file normalize $F = /a/b
>
> OLD: file join /tmp /a/b -> /a/b
> NEW: file concat /tmp /a/b -> /tmp/a/b
>
>

Your solution *will fail* under MS-Windows (and maybe MacOSX). I *think* file
normalize under MS-Windows might include the drive letter and may swap '/'s
with '\'s. Under MacOSX might result in a path starting with MacOSX root
paths. Note: under Linux (and UNIX) this also happens. This means that you
final result is not going to be a valid existing pathname on any system,
although under UNIX-ish systems it might make some kind of sense, if one is
playing with virtual file systems or something.

> mfg AO
>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Subject: Re: missing command: file concat
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 12 May 2024 13:19 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: missing command: file concat
Date: Sun, 12 May 2024 15:19:05 +0200
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <v1qfk9$2o7rh$1@dont-email.me>
References: <v1q3rr$2lhl0$1@dont-email.me> <v1qc7m$2nfa0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 12 May 2024 15:19:05 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7bc0e0e9debab9b2eb419753abd2c4ad";
logging-data="2891633"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QNupcQftUyOQHXaAGjUPIV5IWHOw11Jc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Jz6otca5dogr1oHibupQpHBeltY=
In-Reply-To: <v1qc7m$2nfa0$1@dont-email.me>
Content-Language: de-DE
View all headers

Am 12.05.24 um 14:21 schrieb greg:
> Am 12.05.24 um 11:58 schrieb aotto1968:
>> Hi,
>>
>> the following code does *not* work :
>>
>> set tmpFile [file join $TMP [ file normalize $F ]]
>>
>> because *file normalize* will return an *absolute* path and *file
>> join* will skip "$TMP" if
>> *absolute* path is found.
>>
>> → the GOAL is to create a new path with *prefix* "$TMP" using the
>> local path separator
>>
>> set tmpFile [file concat $TMP [ file normalize  $F ]]
>>
>> will solve this issue.
>>
>> example:
>>
>> TMP = /tmp
>> file normalize $F = /a/b
>>
>> OLD: file join /tmp /a/b → /a/b
>> NEW: file concat /tmp /a/b → /tmp/a/b
>>
>>
>> mfg AO
>
> # Idea
> #https://wiki.tcl-lang.org/page/namespace+ensemble
> #proc ::tcl::dict::get?
>
> package require fileutil
> proc ::tcl::file::concat {args} {
>   if {[llength $args] != 2} {
>         return -code error "This function expects exactly two arguments"
>     }
>   try {
>     file normalize [file join [lindex $args 0] [fileutil::stripPath
> [lindex [file split [lindex $args 1 ]] 0] [lindex $args 1]]]
>   }
> }
> namespace ensemble configure file -map \
>         [dict merge [namespace ensemble configure file -map] {concat
> ::tcl::file::concat}]
>
> #Example
> puts  [file concat /tmp [pwd]]
>
> #This Tcl script defines a procedure
> #::tcl::file::concat that concatenates two file paths and normalizes the
> result.
>
>
>
> mfg
> Gregor

Works for me here on Linux and Windows.
- check if two arguments
- applies file split to argument 2 to find "root"
- applies fileutil:stripPath along with the "root" and removes the
"root" from argument 2
-applies file join to argument 1 and argument 2
-applies file normalize

Subject: Re: missing command: file concat
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 12 May 2024 16:33 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: missing command: file concat
Date: Sun, 12 May 2024 18:33:51 +0200
Organization: A noiseless patient Spider
Lines: 77
Message-ID: <v1qr1f$2qqq5$1@dont-email.me>
References: <v1q3rr$2lhl0$1@dont-email.me> <v1qc7m$2nfa0$1@dont-email.me>
<v1qfk9$2o7rh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 12 May 2024 18:33:52 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7bc0e0e9debab9b2eb419753abd2c4ad";
logging-data="2976581"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/w7tiPxLTq1dj/Z8L8eKpzYZNSUAdEk7I="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:NuGdWMSVcqZv0LIrmivVsARwDso=
In-Reply-To: <v1qfk9$2o7rh$1@dont-email.me>
Content-Language: de-DE
View all headers

Am 12.05.24 um 15:19 schrieb greg:
> Am 12.05.24 um 14:21 schrieb greg:
>> Am 12.05.24 um 11:58 schrieb aotto1968:
>>> Hi,
>>>
>>> the following code does *not* work :
>>>
>>> set tmpFile [file join $TMP [ file normalize $F ]]
>>>
>>> because *file normalize* will return an *absolute* path and *file
>>> join* will skip "$TMP" if
>>> *absolute* path is found.
>>>
>>> → the GOAL is to create a new path with *prefix* "$TMP" using the
>>> local path separator
>>>
>>> set tmpFile [file concat $TMP [ file normalize  $F ]]
>>>
>>> will solve this issue.
>>>
>>> example:
>>>
>>> TMP = /tmp
>>> file normalize $F = /a/b
>>>
>>> OLD: file join /tmp /a/b → /a/b
>>> NEW: file concat /tmp /a/b → /tmp/a/b
>>>
>>>
>>> mfg AO
>>
>> # Idea
>> #https://wiki.tcl-lang.org/page/namespace+ensemble
>> #proc ::tcl::dict::get?
>>
>> package require fileutil
>> proc ::tcl::file::concat {args} {
>>    if {[llength $args] != 2} {
>>          return -code error "This function expects exactly two arguments"
>>      }
>>    try {
>>      file normalize [file join [lindex $args 0] [fileutil::stripPath
>> [lindex [file split [lindex $args 1 ]] 0] [lindex $args 1]]]
>>    }
>> }
>> namespace ensemble configure file -map \
>>          [dict merge [namespace ensemble configure file -map] {concat
>> ::tcl::file::concat}]
>>
>> #Example
>> puts  [file concat /tmp [pwd]]
>>
>> #This Tcl script defines a procedure
>> #::tcl::file::concat that concatenates two file paths and normalizes
>> the result.
>>
>>
>>
>> mfg
>> Gregor
>
>
>   Works for me here on Linux and Windows.
> - check if two arguments
> - applies file split to argument 2 to find "root"
> - applies fileutil:stripPath along with the "root" and removes the
> "root" from argument 2
> -applies file join to argument 1 and argument 2
> -applies file normalize

#without fileutil::stripPath
in proc ::tcl::file::concat {args}

file normalize [file join [lindex $args 0] {*}[lrange [file split
[lindex $args 1 ]] 1 end]]

Subject: Re: missing command: file concat
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 12 May 2024 16:46 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: missing command: file concat
Date: Sun, 12 May 2024 16:46:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <v1qrou$2qvfl$1@dont-email.me>
References: <v1q3rr$2lhl0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 12 May 2024 18:46:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="0c3ce1d812c22c12a49469d3d83000c5";
logging-data="2981365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fPZrM3cs9eD0EHzrN+xds"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:zCqGBTllJGwLofgvgH+V4M4iR+4=
View all headers

aotto1968 <aotto1968@t-online.de> wrote:
> Hi,
>
> the following code does *not* work :
>
> set tmpFile [file join $TMP [ file normalize $F ]]
>
> because *file normalize* will return an *absolute* path and *file
> join* will skip "$TMP" if *absolute* path is found.

Which is also the exact documented behavior of [file join]. From the
man page (read last two sentences carefully):

file join name ?name ...?
Takes one or more file names and combines them, using the cor‐
rect path separator for the current platform. If a particular
name is relative, then it will be joined to the previous file
name argument. Otherwise, any earlier arguments will be dis‐
carded, and joining will proceed from the current argument.

> → the GOAL is to create a new path with *prefix* "$TMP" using the local path separator

Then one way to do that is to not 'normalize' the one presently being
normalized. Otherwise, if you /really/ need to join a 'normalized'
path then remove the leading path separator after
normalizing:

set tmpFile [file join $TMP [string range [file normalize $F] 1 end]]

Although the above will fail for names beginning with windows drive
letter's or windows UNC paths.

Subject: Re: missing command: file concat
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 12 May 2024 20:16 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: missing command: file concat
Date: Sun, 12 May 2024 22:16:23 +0200
Organization: A noiseless patient Spider
Lines: 82
Message-ID: <v1r82n$2vbh2$1@dont-email.me>
References: <v1q3rr$2lhl0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 12 May 2024 22:16:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="7bc0e0e9debab9b2eb419753abd2c4ad";
logging-data="3124770"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jgnrVPWCCeVsInfIoJq4l3zmaIR7k7GI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:91BjFBAqsPi6zrABlhKw1bNZ4a8=
Content-Language: de-DE
In-Reply-To: <v1q3rr$2lhl0$1@dont-email.me>
View all headers

Am 12.05.24 um 11:58 schrieb aotto1968:
> Hi,
>
> the following code does *not* work :
>
> set tmpFile [file join $TMP [ file normalize $F ]]
>
> because *file normalize* will return an *absolute* path and *file join*
> will skip "$TMP" if
> *absolute* path is found.
>
> → the GOAL is to create a new path with *prefix* "$TMP" using the local
> path separator
>
> set tmpFile [file concat $TMP [ file normalize  $F ]]
>
> will solve this issue.
>
> example:
>
> TMP = /tmp
> file normalize $F = /a/b
>
> OLD: file join /tmp /a/b → /a/b
> NEW: file concat /tmp /a/b → /tmp/a/b
>
>
> mfg AO

Using file split.
Separates the absolute part.
Linux and Windows (unc path)

mfg
Gregor

#! /usr/bin/env tclsh

# Idea from
#https://wiki.tcl-lang.org/page/namespace+ensemble
#proc ::tcl::dict::get?

proc ::tcl::file::concat {args} {
if {[llength $args] != 2} {
return -code error "This function expects exactly two arguments"
}
try {
file normalize [file join [lindex $args 0] {*}[lrange [file split
[lindex $args 1 ]] 1 end]]
}
} namespace ensemble configure file -map \
[dict merge [namespace ensemble configure file -map] {concat
::tcl::file::concat}]

#Examples
puts " [info patchlevel] $tcl_platform(os)"
puts " absolute"
set ndir [pwd]
puts "ndir: $ndir"
puts "file concat [file concat /tmp $ndir]"

puts "\n relative"
set ndir ./greg/tmp
puts "ndir: $ndir"
puts "file concat: [file concat /tmp $ndir]"

puts "\n unc path in windows"
set ndir {\\myserver\files\projects\tcl\info.txt}
puts "ndir: $ndir"
puts "file concat: [file concat /tmp $ndir]"

puts "\n unc path in windows"
set ndir //myserver/files/projects/tcl/info.txt
puts "ndir: $ndir"
puts "file concat: [file concat /tmp $ndir]"

puts "\n unc path in windows"
set ndir //myserver/files/projects/tcl/info.txt
puts "ndir: $ndir"
puts "file concat: [file concat //tmpserver/tmp $ndir]"

Subject: Re: missing command: file concat
From: aotto1968
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 12 May 2024 20:57 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: missing command: file concat
Date: Sun, 12 May 2024 22:57:37 +0200
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <v1rag3$2vtov$1@dont-email.me>
References: <v1q3rr$2lhl0$1@dont-email.me>
<PsicnZhbXfyNJd37nZ2dnZfqnPGdnZ2d@giganews.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 12 May 2024 22:57:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2a81ba49424759bcb52edbe9ab9dec9d";
logging-data="3143455"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sSpFC5rON0j4MwxLlx/YJthNsK+EEUwI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:yowfXpu+N383vXdWtTvDcf/rWT8=
In-Reply-To: <PsicnZhbXfyNJd37nZ2dnZfqnPGdnZ2d@giganews.com>
Content-Language: en-US
View all headers

One reason to introduce the *file concat* is that windows etc add a lot of extra chars.
I'm on unix *without* drive-letter etc

some restrictions:
1) the windows-file-letter should be skipped *or* be first part of the path

file concat c:\tmp d:\a\b → c:\tmp\a\b … or … c:\tmp\_d_\a\b

the *goal* of this is to make a kind of "backup" from an exiting file with path into a *tmp* directory
*and* keep the directory-tree valid

I think "wget" is doing something like this to copy a html-tree on to disc

On 12.05.24 14:37, Robert Heller wrote:
> At Sun, 12 May 2024 11:58:19 +0200 aotto1968 <aotto1968@t-online.de> wrote:
>
>>
>> Hi,
>>
>> the following code does *not* work :
>>
>> set tmpFile [file join $TMP [ file normalize $F ]]
>>
>> because *file normalize* will return an *absolute* path and *file join* will skip "$TMP" if
>> *absolute* path is found.
>>
>> - the GOAL is to create a new path with *prefix* "$TMP" using the local path separator
>
> Why would you really want to do that? Please explain your use case...
>
>>
>> set tmpFile [file concat $TMP [ file normalize $F ]]
>>
>> will solve this issue.
>>
>> example:
>>
>> TMP =tmp
>> file normalize $F =a/b
>>
>> OLD: file join /tmp /a/b -> /a/b
>> NEW: file concat /tmp /a/b -> /tmp/a/b
>>
>>
>
> Your solution *will fail* under MS-Windows (and maybe MacOSX). I *think* file
> normalize under MS-Windows might include the drive letter and may swap '/'s
> with '\'s. Under MacOSX might result in a path starting with MacOSX root
> paths. Note: under Linux (and UNIX) this also happens. This means that you
> final result is not going to be a valid existing pathname on any system,
> although under UNIX-ish systems it might make some kind of sense, if one is
> playing with virtual file systems or something.
>
>
>> mfg AO
>>
>>
>

Subject: Re: missing command: file concat
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Mon, 13 May 2024 02:39 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-3.nntp.ord.giganews.com!border-4.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 13 May 2024 02:39:52 +0000
MIME-Version: 1.0
From: heller@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.17)
Subject: Re: missing command: file concat
In-Reply-To: <v1rag3$2vtov$1@dont-email.me>
References: <v1q3rr$2lhl0$1@dont-email.me>?
<PsicnZhbXfyNJd37nZ2dnZfqnPGdnZ2d@giganews.com>
<v1rag3$2vtov$1@dont-email.me>
Newsgroups: comp.lang.tcl
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <2IqcnfMF6I_l4Nz7nZ2dnZfqnPSdnZ2d@giganews.com>
Date: Mon, 13 May 2024 02:39:52 +0000
Lines: 80
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-Ruwn4J61qf4qlexpXS4dVLjIUFsqnVO9+omYshI90kCaH7rCb87SVPIIeLU5VvPSoleKzImgfmTgijg!ynFxdXa0nSSGAfPYsBExHjM++obBip2mEN32zXULUdLGaiVWBjSntFlzA0lua3elkLRZuMvohlGj!OVA=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

At Sun, 12 May 2024 22:57:37 +0200 aotto1968 <aotto1968@t-online.de> wrote:

>
>
> One reason to introduce the *file concat* is that windows etc add a lot of extra chars.
> I'm on unix *without* drive-letter etc
>
> some restrictions:
> 1) the windows-file-letter should be skipped *or* be first part of the path
>
> file concat c:\tmp d:\a\b → c:\tmp\a\b … or … c:\tmp\_d_\a\b
>
> the *goal* of this is to make a kind of "backup" from an exiting file with path into a *tmp* directory
> *and* keep the directory-tree valid
>
> I think "wget" is doing something like this to copy a html-tree on to disc

I suspect wget is doing something else.

I think "file normalize" is not really needed or wanted. Maybe a different
function to "just" deal with "../" and "./" segments, but not a full
normalization to an abs path is really what you want.

>
>
> On 12.05.24 14:37, Robert Heller wrote:
> > At Sun, 12 May 2024 11:58:19 +0200 aotto1968 <aotto1968@t-online.de> wrote:
> >
> >>
> >> Hi,
> >>
> >> the following code does *not* work :
> >>
> >> set tmpFile [file join $TMP [ file normalize $F ]]
> >>
> >> because *file normalize* will return an *absolute* path and *file join* will skip "$TMP" if
> >> *absolute* path is found.
> >>
> >> - the GOAL is to create a new path with *prefix* "$TMP" using the local path separator
> >
> > Why would you really want to do that? Please explain your use case...
> >
> >>
> >> set tmpFile [file concat $TMP [ file normalize $F ]]
> >>
> >> will solve this issue.
> >>
> >> example:
> >>
> >> TMP =tmp
> >> file normalize $F =a/b
> >>
> >> OLD: file join /tmp /a/b -> /a/b
> >> NEW: file concat /tmp /a/b -> /tmp/a/b
> >>
> >>
> >
> > Your solution *will fail* under MS-Windows (and maybe MacOSX). I *think* file
> > normalize under MS-Windows might include the drive letter and may swap '/'s
> > with '\'s. Under MacOSX might result in a path starting with MacOSX root
> > paths. Note: under Linux (and UNIX) this also happens. This means that you
> > final result is not going to be a valid existing pathname on any system,
> > although under UNIX-ish systems it might make some kind of sense, if one is
> > playing with virtual file systems or something.
> >
> >
> >> mfg AO
> >>
> >>
> >
>
>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

1

rocksolid light 0.9.8
clearnet tor