GithubHelp home page GithubHelp logo

Comments (5)

Cj-bc avatar Cj-bc commented on July 27, 2024

I tryed some, so report them.

For all of below codes, I modified util/exception.sh a little bit:

  28 command_not_found_handle() {
+ 29   echo $@
  30   # USE DEFAULT IFS IN CASE IT WAS CHANGED
  31   local IFS=$' \t\n'
  32
  1. change throw alias to pass $1 to command_not_found_handle

Purpose: To check whether $1 will be passed to command_not_found_handle
Result: the argunment was not passed as $1

Tried to check whether alias is the problem:

# modified code: in util/exception.sh
alias throw="__EXCEPTION_TYPE__=\${e:-Manually invoked} command_not_found_handle hoge"

# my script is the same one as above
# outputs
throw

 ✘ UNCAUGHT EXCEPTION: Undefined command (throw)
    ➦ Undefined command [oo-bootstrap.sh:84]
    ✘ System::SourcePath "${__oo__path}/${libPath}" "$@" || e="Cannot import $libPath" throw [oo-bootstrap.sh:84]
       ➦ System::ImportOne "$libPath" [oo-bootstrap.sh:96]
          ➦ System::Import [command_not_found_handle_test.sh:3]
          ✘ import file_not_exist [command_not_found_handle_test.sh:3]

 ⚡ Press [CTRL+C] to exit or [Return] to continue execution.

hoge, which was pessed as $1 is not shown as one of the $@.

I have no idea what's happen here...omg
(I searched if there're other definitions for throw and command_not_found_handle,
but I couldn't find anymore than I know.)(searched by using git grep)

  1. call throw manually from my script

Purpose: To check whether throw works correctly in other cases
Result: It worked

It seems that throw works fine for manually executing.

I tested to call throw by myself in my test script:

import util/exception util/log util/tryCatch

  e="hello. test" throw "this is just atest"

then outputs:

 ✘ UNCAUGHT EXCEPTION: hello. test (this is just atest)
    e="➦ hello. test" throw "this is just atest" [command_not_found_handle_test.sh:9]

 ⚡ Press [CTRL+C] to exit or [Return] to continue execution.
⚙  Continuing...

3.1 call throw from my function

Purpose: To check whether function do something bad
Result: It worked

Call throw in my function

# my script
import util/exception util/log util/tryCatch

testfunc() {
  e="hello. test" throw "this is just atest"
}
testfunc

#
# outputs
this is just atest

 ✘ UNCAUGHT EXCEPTION: hello. test (hoge)
    e="hello. test" throw "➦ this is just atest" [command_not_found_handle_test.sh:13]
       ➦ testfunc [command_not_found_handle_test.sh:16]

 ⚡ Press [CTRL+C] to exit or [Return] to continue execution.

3.2 call throw from my function. excecute the function using alias

Purpose: To check whether alias do something bad
Result: It worked

Using testfunc in 3.1, but call it using alias

# my script
import util/exception util/log util/tryCatch

testfunc() {
  e="hello. test" throw "this is just atest"
}

alias ali="testfunc"
ali

# outputs
this is just atest

 ✘ UNCAUGHT EXCEPTION: hello. test (this is just atest)
    e="➦ hello. test" throw "this is just atest" [command_not_found_handle_test.sh:13]
       alias ali="➦ testfunc" [command_not_found_handle_test.sh:16]

 ⚡ Press [CTRL+C] to exit or [Return] to continue execution.
⚙  Continuing...

from bash-oo-framework.

Cj-bc avatar Cj-bc commented on July 27, 2024

sorry, this is not a bug of this framework, probably.
I tried with a simple snipet which does not use oo- framework and got the same result.
As I'm away from my PC, I'll post the code later.

from bash-oo-framework.

Cj-bc avatar Cj-bc commented on July 27, 2024

Here's the code!!

#!/usr/bin/env bash


alias test_a="command_not_found_handle"

command_not_found_handle() {
echo $*
}

test_a # call function using alias
echo '----'
command_not_found_handle # call function directly

and here's outputs:

$?is0[bugfix/throw-puts-wrong-exception]
<X_X>:bash-oo-framework$ ./test_throw_bug.sh # the above code
test_a
----

$?is0[bugfix/throw-puts-wrong-exception]

from bash-oo-framework.

niieani avatar niieani commented on July 27, 2024

It seems like a bash bug: even when the alias throw is declared at the very beginning, it seems unavailable within the body of the System::ImportOne function.

We can think about a good solution when planning for #45.

from bash-oo-framework.

Cj-bc avatar Cj-bc commented on July 27, 2024

I sent a bug-report to bash by using bashbug.
I hope this will be fixed someday...

If I find good solution, I'll post it to #45

And... Should we close this issue?

from bash-oo-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.