[Cuis-dev] fix for leading tilda in DirectoryEntry, or am I going about this the wrong way?

Imran Rafique imran at rafique.org
Thu Jul 27 07:07:02 PDT 2023


Juan & Hernan,

I **think** the attached changeset does what you wanted. I may have
overcomplicated things somewhat, but in any case, its a great learning
experience.


Gives an exception if OSProcess is not available:

    '~/foo' asFileEntry.


Sets a default homedir in case we cannot read environment variables:

    [ '~/foo' asDirectoryEntry ] on: NeedsPackage do: [ :ex |
FileIOAccessor homeDirDefault: '/home/guess'. ex retry ]


BTW, whats the preferred way of including tests for changesets like this?

--
Regards,
       Imran Sher Rafique

On Mon, 24 Jul 2023 at 06:31, Hernán Wilkinson
<hernan.wilkinson at 10pines.com> wrote:
>
> I agree with you Juan.
> Even signal an exception or change/add the/a message to get a block to be evaluated in case of not having OSProcess (like at:ifAbsent:).
>
> Cheers!
> Hernan.
>
> On Mon, Jul 24, 2023 at 10:28 AM Juan Vuletich via Cuis-dev <cuis-dev at lists.cuis.st> wrote:
>>
>> Hi Imran,
>>
>> I agree you identified a problem. But I don't like to interpret '~' as
>> two different folders depending on the presence of OSProcess.
>>
>> I think that the correct behavior would be to give an error message if
>> OSProcess is not present.
>>
>> What do others think?
>>
>> Thanks,
>>
>> On 7/24/2023 10:08 AM, Imran Rafique via Cuis-dev wrote:
>> > Hello list,
>> >
>> > I'm hesitant to call this a bugfix, as its quite possible (probable?)
>> > that I'm going about this the wrong way (or I've grasped the wrong end
>> > of the stick), but here goes:
>> >
>> > Original behaviour:
>> >      '~/foo' asDirectoryEntry  =>   <image_dir>/foo
>> >
>> > Should be:
>> >      <user_home_dir>/foo
>> >
>> > I think I understand the real issue: without OSProcess, there's no way
>> > for the system to know what $HOME is. Perhaps<image_dir>  is
>> > considered as a reasonable fallback (in which case, disregard the rest
>> > of this).
>> >
>> > Details:
>> > - the attached changeset is a manually-extracted portion of one of my
>> > local packages (with just the code pertaining to this issue)
>> > - it modifies FileIOAccessor>>  absolutePathComponentsFor:  so that it
>> > behaves differently and correctly interprets '~' ONLY if OSProcess is
>> > loaded.
>> > - which means that DirectoryEntry would give different answers for the
>> > same '~/whatever' depending on the state of the image. This is
>> > probably bad practice on my part, but anyway, it was annoying me.
>> >
>> >
>> > If this is a bogus fix, please excuse the noise to the list. Either
>> > way, the learning experience is a blast (just starting to get the hang
>> > of the debugger).
>> >
>> > --
>> > Regards,
>> >         Imran Sher Rafique
>>
>>
>> --
>> Juan Vuletich
>> cuis.st
>> github.com/jvuletich
>> researchgate.net/profile/Juan-Vuletich
>> independent.academia.edu/JuanVuletich
>> patents.justia.com/inventor/juan-manuel-vuletich
>> linkedin.com/in/juan-vuletich-75611b3
>> twitter.com/JuanVuletich
>>
>> --
>> Cuis-dev mailing list
>> Cuis-dev at lists.cuis.st
>> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
>
>
> --
> Hernán Wilkinson
> Agile Software Development, Teaching & Coaching
> Phone: +54-011-4893-2057
> Twitter: @HernanWilkinson
> site: http://www.10Pines.com
> Address: Alem 896, Floor 6, Buenos Aires, Argentina
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 5951-FixTildaExpansionInFiles-ImranSherRafique-2023Jul27-03h29m-isr.001.cs.st
Type: application/octet-stream
Size: 4344 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230727/9042c140/attachment.obj>


More information about the Cuis-dev mailing list