[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hi, this is student studying bash. (typeset question)

From: ironhopper
Subject: hi, this is student studying bash. (typeset question)
Date: Tue, 29 Sep 2020 12:40:36 +0900
User-agent: Roundcube Webmail/1.4.6

Dear gnu team.

hi, I'm studying embedded system and bash these days.
but little confusing about type system.
where is integer type definition code?

I read linux documentation project's docs.

doc1: bash distinguish values into string and integer and so on.
doc2: it is possible to declare some types.
doc3: middle of doc,
Integer variables in older versions of Bash were signed long (32-bit) integers, in the range of -2147483648 to 2147483647. An operation that took a variable outside these limits gave an erroneous result.

but I cannot find the code related it. <integer variables were signed long, but now 64-bit>

I downloaded bash source files on websites.
versions are bash-1.14.7, bash-2.05a, bash-2.05b, and bash-5.0
and now comparing each versions.

the question is
<strong> where can I find integer type definition code? <strong>

I found some code like below.
-- variables.h -- version 2.05b
/* For the future */
union _value {
  char *s;                      /* string value */
  intmax_t i;                   /* int value */
  COMMAND *f;                   /* function */
  ARRAY *a;                     /* array */
  HASH_TABLE *h;                /* associative array */
  double d;                     /* floating point number */
  void *v;                      /* opaque data for future use */

-- variables.h -- version 2.05a
/* The various attributes that a given variable can have. */
#define att_exported  0x001     /* export to environment */
#define att_readonly  0x002     /* cannot change */
#define att_invisible 0x004     /* cannot see */
#define att_array     0x008     /* value is an array */
#define att_nounset   0x010     /* cannot unset */
#define att_function  0x020     /* value is a function */
#define att_integer   0x040     /* internal representation is int */
#define att_imported  0x080     /* came from environment */
#define att_local     0x100     /* variable is local to a function */
#define att_tempvar 0x200 /* variable came from the temp environment */ #define att_importstr 0x400 /* exportstr points into initial environment */
#define att_noassign  0x800     /* assignment not allowed */

#define exported_p(var)         ((((var)->attributes) & (att_exported)))
#define readonly_p(var)         ((((var)->attributes) & (att_readonly)))
#define invisible_p(var)        ((((var)->attributes) & (att_invisible)))
#define array_p(var)            ((((var)->attributes) & (att_array)))
#define non_unsettable_p(var)   ((((var)->attributes) & (att_nounset)))
#define function_p(var)         ((((var)->attributes) & (att_function)))
#define integer_p(var)          ((((var)->attributes) & (att_integer)))
#define imported_p(var)         ((((var)->attributes) & (att_imported)))
#define local_p(var)            ((((var)->attributes) & (att_local)))
#define tempvar_p(var)          ((((var)->attributes) & (att_tempvar)))
#define noassign_p(var)         ((((var)->attributes) & (att_noassign)))

It's my first time to find some code from the whole big program like bash. It's very interesting and exciting work but also very difficult as beginner's view.

if possible, Would you let me know the file name which gnu team usually set the configurations like type definitions?(projects structure)
someday studying more and more, I want support many other gnu projects!

Thank GNU for everything we use.

Sincerely, ironhopper(nickname).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]