Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.os.linux > #59465

Re: type of Bash variables

From Soviet_Mario <SovietMario@CCCP.MIR>
Newsgroups alt.os.linux
Subject Re: type of Bash variables
Date 2019-10-12 20:43 +0200
Organization A noiseless patient Spider
Message-ID <qnt6rm$8q8$1@dont-email.me> (permalink)
References <qnsv2d$o6i$1@dont-email.me> <qnsvvf$u80$1@dont-email.me> <qnt393$j7d$1@dont-email.me> <qnt5sh$350$1@dont-email.me>

Show all headers | View raw


Il 12/10/19 20:26, Paul ha scritto:
> Soviet_Mario wrote:
>> Il 12/10/19 18:45, Chris Elvidge ha scritto:
>>> On 12/10/2019 17:30, Soviet_Mario wrote:
>>>>
>>>> Are Bash variables able to be assigned or have a TYPE ?
>>>> I mean, can they be assigned numbers or dates considered 
>>>> not as strings but as typed items ?
>>> They can be any type.
>>>>
>>>> Is it there some command to inquire on such (possible) 
>>>> type ?
>>>>
>>>> I'm asking this for reliable comparisons not depending 
>>>> on readable human formats, but using the internal binary 
>>>> representation of data
>>> What?
>>
>> I mean, when you execute DATE and it outputs the current 
>> date-time, it converts from the native internal format to 
>> human readable with the locale.
>> I'd like to know if it is possible to grab directly the 
>> internal representation (same for numbers) and not the 
>> output text, in order to get efficient (and RELIABLE) 
>> comparisons to other date-times ...
>>
>>>>
>>>> I'm getting very surprising results trying to do 
>>>> algebric operation on dates output, like string 
>>>> truncations and so
>>>>
>>>>
>>> Perhaps if you gave an example or two of the surprises, 
>>> we would be able to help further.
>>>
>>
>> I mean such exhilarating things like these
>>
>> gattovizzato@dhcppc0:~$ dt=$(date)
>> gattovizzato@dhcppc0:~$ echo $dt
>> sab 12 ott 2019, 18.03.07, CEST
>> gattovizzato@dhcppc0:~$ dt=($dt-1)
>> gattovizzato@dhcppc0:~$ echo $dt
>> sab
>> gattovizzato@dhcppc0:~$ dt=($dt+1)
>> gattovizzato@dhcppc0:~$ echo $dt
>> sab+1
>>
>> I was trying to add "something" (month ? second ? hour ? 
>> day ? year ?) to a date :)
> 
> This isn't shell, but you could try to prepare
> an executable for the job.
> 
> https://linux.die.net/man/3/clock_gettime
> 
> What I did, is used these calls I use in Windows
> 
>      QueryPerformanceCounter((LARGE_INTEGER *) &time1);
>      QueryPerformanceFrequency((LARGE_INTEGER *)&freq);
> 
> and ask Google for the equivalent in Linux, and that
> was the answer I got, to use clock_gettime. Then,
> by specifying the correct option (say CLOCK_REALTIME),
> you might get something similar to shell DATE. With
> some luck, the clock has a resolution of around 100ns
> or so.
> 
> You don't want to be doing "maths" on the string
> that DATE returns. Think of all the programmatic
> "holes" you can fall into, such as the time interval
> near the "time change" (daylight savings time). You
> want to work with a single monotonic number used by
> the system, add a manifest constant to that value,
> *then* call a conversion routine to make an actual
> string from it. Try to get as much value from all
> of that time code running on your system, as possible.
> 
> Working with "time" is always dangerous as a programmer,
> no matter what level you work at. There are a million
> things to know, and many many traps for the unwary
> programmer. And on the USENET, there are a few
> "Time Lords" who will tear apart and make fun
> of your code :-)
> 
>     Paul


hi paul, I was tinkering with bash as I'm getting stuck with 
gambas shell function (it simply hangs and the shelled task 
sleeps forever, even if use a flag to wait for its 
completion, then it starts paradoxically only when I 
manually KILL the parent process from task list ... and 
surprisingly it runs till completion).

Normally I was doing dates comparison from within gambas 
ifself, as it replicate stat function and "STATS" files, 
then simple memberwise comparison of fields (atime, mtime, 
etc) works well, hiding all human datetime representation => 
STATS uses internal representation

then I had the very sick insane idea to try sth with bash. 
And it's like assuming an overdose of LSD :)

Im becoming convinced bash was created by sb able to love 
even PERL :) :\ :o

-- 
1) Resistere, resistere, resistere.
2) Se tutti pagano le tasse, le tasse le pagano tutti
Soviet_Mario - (aka Gatto_Vizzato)

Back to alt.os.linux | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-12 18:30 +0200
  Re: type of Bash variables Chris Elvidge <chris@mshome.net> - 2019-10-12 17:45 +0100
    Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-12 19:41 +0200
      Re: type of Bash variables Bit Twister <BitTwister@mouse-potato.com> - 2019-10-12 12:57 -0500
        Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-12 20:32 +0200
          Re: type of Bash variables William Unruh <unruh@invalid.ca> - 2019-10-13 14:47 +0000
            Re: type of Bash variables "David W. Hodgins" <dwhodgins@nomail.afraid.org> - 2019-10-13 11:12 -0400
              Re: type of Bash variables Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> - 2019-10-17 17:59 +1100
      Re: type of Bash variables "David W. Hodgins" <dwhodgins@nomail.afraid.org> - 2019-10-12 14:05 -0400
        Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-12 20:36 +0200
          Re: type of Bash variables "David W. Hodgins" <dwhodgins@nomail.afraid.org> - 2019-10-12 16:02 -0400
      Re: type of Bash variables Paul <nospam@needed.invalid> - 2019-10-12 14:26 -0400
        Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-12 20:43 +0200
          Re: type of Bash variables Paul <nospam@needed.invalid> - 2019-10-12 15:18 -0400
            Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-12 22:44 +0200
        Re: type of Bash variables Ken Hart <kwhart1@frontier.com> - 2019-10-12 18:11 -0400
          Re: type of Bash variables "Carlos E.R." <robin_listas@es.invalid> - 2019-10-13 09:16 +0200
      Re: type of Bash variables Jasen Betts <jasen@xnet.co.nz> - 2019-10-12 20:20 +0000
        Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-13 10:41 +0200
      Re: type of Bash variables "Carlos E.R." <robin_listas@es.invalid> - 2019-10-13 08:18 +0200
      Re: type of Bash variables Chris Elvidge <chris@mshome.net> - 2019-10-13 11:23 +0100
        Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-13 13:40 +0200
      Re: type of Bash variables William Unruh <unruh@invalid.ca> - 2019-10-13 14:43 +0000
    Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-12 19:44 +0200
  Re: type of Bash variables Bit Twister <BitTwister@mouse-potato.com> - 2019-10-12 12:06 -0500
    Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-12 19:48 +0200
  Re: type of Bash variables Richard Kettlewell <invalid@invalid.invalid> - 2019-10-13 08:58 +0100
    Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-13 10:38 +0200
  Re: type of Bash variables William Unruh <unruh@invalid.ca> - 2019-10-13 14:36 +0000
    Re: type of Bash variables Soviet_Mario <SovietMario@CCCP.MIR> - 2019-10-13 20:58 +0200
      Re: type of Bash variables gazelle@shell.xmission.com (Kenny McCormack) - 2019-10-13 19:04 +0000
      Re: type of Bash variables William Unruh <unruh@invalid.ca> - 2019-10-13 19:28 +0000

csiph-web